H,W = list(map(int,input().split())) sy,sx = list(map(lambda x:int(x)-1,input().split())) gy,gx = list(map(lambda x:int(x)-1,input().split())) dy = [-1,1,0,0] dx = [0,0,-1,1] visited = [[False for _ in range(W)] for _ in range(H)] ans = 0 def f(y,x): if(y == gy and x == gx): global ans ans += 1 return visited[y][x] = True for i in range(4): next_y = y + dy[i] next_x = x + dx[i] if(next_y < 0 or H <= next_y):continue if(next_x < 0 or W <= next_x):continue if(visited[next_y][next_x]):continue count = 0 for j in range(4): next_next_y = next_y + dy[j] next_next_x = next_x + dx[j] if(next_next_y < 0 or H <= next_next_y):continue if(next_next_x < 0 or W <= next_next_x):continue count += visited[next_next_y][next_next_x] if(count >= 2):continue f(next_y,next_x) visited[y][x] = False f(sy,sx) print(ans)