H,W=map(int,input().split()) s0,s1=map(int,input().split()) g0,g1=map(int,input().split()) s0-=1;s1-=1 g0-=1;g1-=1 queue=[[(s0,s1)]] ans=0 while queue: route=queue.pop() x,y=route[-1] if (x,y)==(g0,g1): ans+=1 for dx,dy in ((0,1),(1,0),(0,-1),(-1,0)): if 0<=x+dx=2 for xx,yy in route[:-1]): queue.append(route+[(x+dx,y+dy)]) print(ans)