#include using namespace std; using ll = long long; void culc(int &ans, set> &st, pair now, int h, int w, pair g) { vector> v; if (now.first != 1) v.push_back({now.first - 1, now.second}); if (now.first != h) v.push_back({now.first + 1, now.second}); if (now.second != 1) v.push_back({now.first, now.second - 1}); if (now.second != w) v.push_back({now.first, now.second + 1}); for (auto p : v) { if (st.count(p) == 1) continue; int cnt = 0; vector> dx = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; for (int i = 0; i < 4; i++) { if (st.count({p.first + dx[i].first, p.second + dx[i].second}) == 1) cnt++; } if (cnt > 1) continue; if (p == g) ans++; else { st.insert(p); culc(ans, st, p, h, w, g); st.erase(p); } } } void solve() { int h, w; cin >> h >> w; pair s, g; cin >> s.first >> s.second >> g.first >> g.second; int ans = 0; set> st; st.insert(s); culc(ans, st, s, h, w, g); cout << ans << endl; } int main() { std::cin.tie(0)->sync_with_stdio(0); cout << setprecision(20); int CNT = 1; for (int i = 0; i < CNT; i++) solve(); }