#include <bits/stdc++.h>
using namespace std;
long long parte(long long a, long long b) {
  long long q = a / b;
  if (a >= 0) return q;
  if (q * b == a) return q;
  return q - 1;
}
int main() {
  long long a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  long long C = parte(c + d, a + a), D = parte(d - c, b + b);
  long long E = parte(e + f, a + a), F = parte(f - e, b + b);
  cout << max(abs(C - E), abs(D - F)) << endl;
}
