#include <bits/stdc++.h>
using namespace std;
long long a, b, x1, y11, x2, y2, ans;
long long r0(long long a, long long b) {
  if (a < 0 && a % b != 0)
    return a / b - 1;
  else
    return a / b;
}
int main() {
  cin >> a >> b >> x1 >> y11 >> x2 >> y2;
  a *= 2, b *= 2;
  int ans = 0;
  if (abs(x1 + y11) % a == 0) {
    ans = 1 + abs(x1 + y11 - x2 - y2) / a;
  } else if (abs(x2 + y2) % a == 0) {
    ans = 1 + abs(x1 + y11 - x2 - y2) / a;
  } else {
    ans = abs(r0(x1 + y11, a) - r0(x2 + y2, a));
  }
  long long as = ans;
  if (abs(x1 - y11) % b == 0) {
    ans += 1 + abs(x1 - y11 - x2 + y2) / b;
  } else if (abs(x2 - y2) % b == 0) {
    ans += 1 + abs(x1 - y11 - x2 + y2) / b;
  } else
    ans += abs(r0(x1 - y11, b) - r0(x2 - y2, b));
  if (as > 0 && ans > as) ans = max(as, ans - as);
  cout << ans << endl;
  return 0;
}
