#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const int N = 1e3 + 10;
long long getans(long long x1, long long x2, long long d) {
  if (x1 < 0) x1 = -x1, x2 = -x2;
  if (x1 < x2) swap(x1, x2);
  long long o = (x1 + d - 1) / d;
  x1 -= d * o;
  x2 -= d * o;
  swap(x1, x2);
  return x2 / d - x1 / d;
}
int main() {
  int a, b, x1, y1, x2, y2;
  cin >> a >> b >> x1 >> y1 >> x2 >> y2;
  cout << max(getans(x1 + y1, x2 + y2, a * 2), getans(x1 - y1, x2 - y2, b * 2))
       << endl;
  return 0;
}
