H, W = map(int, input().split()) Si, Sj = map(int, input().split()) Si, Sj = Si - 1, Sj - 1 Gi, Gj = map(int, input().split()) Gi, Gj = Gi - 1, Gj - 1 vis = [[False] * W for _ in range(H)] ans = 0 D = [(1, 0), (0, 1), (-1, 0), (0, -1)] def dfs(i, j): if (i, j) == (Gi, Gj): global ans ans += 1 vis[i][j] = True for di, dj in D: ni, nj = i + di, j + dj if 0 <= ni < H and 0 <= nj < W and not vis[ni][nj]: ok = True for di, dj in D: nni, nnj = ni + di, nj + dj if (nni, nnj) == (i, j): continue if 0 <= nni < H and 0 <= nnj < W and vis[nni][nnj]: ok = False break if ok: dfs(ni, nj) vis[i][j] = False dfs(Si, Sj) print(ans)