#include <bits/stdc++.h>
using namespace std;
long long abs2(long long a) { return a >= 0 ? a : -a; }
long long calc(long long k, long long a) {
  if (k >= 0) return k / a;
  return (k - (a - 1)) / a;
}
long long calc2(long long a1, long long b1, long long a2, long long b2) {
  long long x = abs2(a1 - a2) + abs2(b2 - (a2 + (b1 - a1)));
  long long y = abs2(a1 - a2) + abs2(b2 - (-a2 + a1 + b1));
  return min(x, y);
}
int main() {
  long long a, b, x1, x2, y1, y2;
  while (cin >> a >> b >> x1 >> y1 >> x2 >> y2) {
    long long a1, b1;
    long long a2, b2;
    a1 = calc(x1 + y1, 2 * a);
    b1 = calc(x1 - y1, 2 * b);
    a2 = calc(x2 + y2, 2 * a);
    b2 = calc(x2 - y2, 2 * b);
    long long x = calc2(a1, b1, a2, b2);
    long long y = calc2(b1, a1, b2, a2);
    cout << (int)min(x, y) << endl;
  }
  return 0;
}
