#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, x1, y1, x2, y2;
  cin >> a >> b >> x1 >> y1 >> x2 >> y2;
  long long tx1, ty1, tx2, ty2;
  tx1 = x1 - y1;
  ty1 = x1 + y1;
  tx2 = x2 - y2;
  ty2 = x2 + y2;
  if (tx1 < 0) tx1 -= 2 * b;
  if (ty1 < 0) ty1 -= 2 * a;
  if (tx2 < 0) tx2 -= 2 * b;
  if (ty2 < 0) ty2 -= 2 * a;
  tx1 /= 2 * b;
  ty1 /= 2 * a;
  tx2 /= 2 * b;
  ty2 /= 2 * a;
  int min = 0;
  tx1 -= tx2;
  if (tx1 < 0) tx1 *= -1;
  ty1 -= ty2;
  if (ty1 < 0) ty1 *= -1;
  min = tx1 > ty1 ? tx1 : ty1;
  cout << min << endl;
  return 0;
}
