import sys sys.setrecursionlimit(10**5) ways = set([(0, 1), (0, -1), (1, 0), (-1, 0)]) H, W = map(int, input().split()) S_i, S_j = map(lambda x: int(x) - 1, input().split()) G_i, G_j = map(lambda x: int(x) - 1, input().split()) grid = [[0 for _ in range(W)] for _ in range(H)] ans = 0 def next_hop(now_i, now_j): for di, dj in ways: next_i, next_j = now_i + di, now_j + dj if 0 <= next_i < H and 0 <= next_j < W: yield next_i, next_j def dfs(now_i, now_j): global ans if now_i == G_i and now_j == G_j: ans += 1 return grid[now_i][now_j] += 1 for next_i, next_j in next_hop(now_i, now_j): grid[next_i][next_j] += 1 for next_i, next_j in next_hop(now_i, now_j): if grid[next_i][next_j] <= 1: dfs(next_i, next_j) grid[now_i][now_j] -= 1 for next_i, next_j in next_hop(now_i, now_j): grid[next_i][next_j] -= 1 dfs(S_i, S_j) print(ans)