#include <bits/stdc++.h>
using namespace std;
const int maxn = 10005;
const int inf = 0x3fffffff;
const double eps = 1e-8;
const double pi = acos(-1.0);
long long get1(long long x, long long y, long long a) {
  long long tmp = x + y;
  if (tmp < 0) {
    return tmp / a - 1;
  }
  return tmp / a;
}
long long get2(long long x, long long y, long long b) {
  long long tmp = y - x;
  if (tmp < 0) {
    return tmp / b - 1;
  }
  return tmp / b;
}
int main(int argc, char *argv[]) {
  long long a, b, x1, y1, x2, y2;
  while (scanf("%I64d%I64d%I64d%I64d%I64d%I64d", &a, &b, &x1, &y1, &x2, &y2) !=
         EOF) {
    if (a == 1 || b == 1) {
      long long ans = (abs(y1 - y2) + 1) / 2 + (abs(x1 - x2) + 1) / 2;
      printf("%I64d\n", ans);
      continue;
    }
    a <<= 1, b <<= 1;
    long long n1 = get1(x1, y1, a), n2 = get1(x2, y2, a);
    long long m1 = get2(x1, y1, b), m2 = get2(x2, y2, b);
    long long ans1 = abs(n1 - n2), ans2 = abs(m1 - m2);
    printf("%I64d\n", max(ans1, ans2));
  }
  return 0;
}
