#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
template <class T>
T abs(const T& a) {
  return a > 0 ? a : -a;
}
template <class T>
int sgn(const T& a) {
  return a > 0 ? 1 : (a < 0 ? -1 : 0);
}
const double PI = 2.0 * acos(1.0);
int n;
int m;
long long Div(long long a, long long b) {
  long long c = a / b + 10;
  while (c * b > a) c--;
  return c;
}
int main() {
  long long a, b, x1, y28435, x2, y2;
  cin >> a >> b >> x1 >> y28435 >> x2 >> y2;
  if (a == 1 || b == 1) {
    long long l = abs(x1 - x2) + abs(y28435 - y2) + 1;
    cout << l / 2 << endl;
    return 0;
  }
  long long xx1 = Div(x1 + y28435, 2 * a);
  long long yy1 = Div(x1 - y28435, 2 * b);
  long long xx2 = Div(x2 + y2, 2 * a);
  long long yy2 = Div(x2 - y2, 2 * b);
  cout << max(abs(xx1 - xx2), abs(yy1 - yy2)) << endl;
  return 0;
}
