using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (h, w) = (c[0], c[1]); c = NList; var (si, sj) = (c[0] - 1, c[1] - 1); c = NList; var (gi, gj) = (c[0] - 1, c[1] - 1); var map = new int[h][]; for (var i = 0; i < h; ++i) map[i] = Enumerable.Repeat(100, w).ToArray(); map[si][sj] = 0; WriteLine(DFS(h, w, si, sj, gi, gj, map)); } static int[] mx = new int[] { -1, 1, 0, 0 }; static int[] my = new int[] { 0, 0, -1, 1 }; static int DFS(int h, int w, int cx, int cy, int gi, int gj, int[][] map) { for (var i = 0; i < 4; ++i) { var nx = cx + mx[i]; var ny = cy + my[i]; if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue; if (map[nx][ny] + 1 < map[cx][cy]) return 0; } if (cx == gi && cy == gj) return 1; var ans = 0; for (var i = 0; i < 4; ++i) { var nx = cx + mx[i]; var ny = cy + my[i]; if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue; if (map[nx][ny] < map[cx][cy]) continue; map[nx][ny] = map[cx][cy] + 1; ans += DFS(h, w, nx, ny, gi, gj, map); map[nx][ny] = 100; } return ans; } }