#include <bits/stdc++.h>
using namespace std;
int get(int x, int y) {
  if (x < 0) return x / y - 1;
  return x / y;
}
int main() {
  int a, b, x1, y1, x2, y2;
  cin >> a >> b >> x1 >> y1 >> x2 >> y2;
  a *= 2, b *= 2;
  int a1 = get(x1 + y1, a), b1 = get(x1 - y1, b);
  int a2 = get(x2 + y2, a), b2 = get(x2 - y2, b);
  int dx = abs(a1 - a2), dy = abs(b1 - b2);
  cout << dx + dy - min(dx, dy);
  return 0;
}
