#include <bits/stdc++.h>
using namespace std;
const long long mod19 = 1000000009;
const long long mod17 = 1000000007;
int get(int s, int e, int mod) {
  mod <<= 1;
  if (s > e) swap(s, e);
  s = s / mod + (s >= 0);
  e = e / mod + (e >= 0);
  return abs(e - s);
}
int main() {
  int a, b, x[2], y[2];
  cin >> a >> b >> x[0] >> y[0] >> x[1] >> y[1];
  int sx[2], sy[2];
  sx[0] = y[0] + x[0];
  sy[0] = y[0] - x[0];
  sx[1] = y[1] + x[1];
  sy[1] = y[1] - x[1];
  cout << max(get(sx[1], sx[0], a), get(sy[1], sy[0], b));
  return 0;
}
