#include <bits/stdc++.h>
using namespace std;
long long down(long long a, long long b) {
  long long d = a / b;
  while (d * b > a) --d;
  return d;
}
int main() {
  long long a, b, A, B, x1, x2, y1, y2;
  long long a1, a2, b1, b2;
  cin >> a >> b >> x1 >> y1 >> x2 >> y2;
  a1 = down((x1 + y1), (2 * a));
  a2 = down((x2 + y2), (2 * a));
  b1 = down((x1 - y1), (2 * b));
  b2 = down((x2 - y2), (2 * b));
  if (a1 == a2)
    A = 0;
  else {
    if (a1 > a2)
      ++a2;
    else if (a2 > a1)
      ++a1;
    A = 1 + abs(a1 - a2);
  }
  if (b1 == b2)
    B = 0;
  else {
    if (b1 > b2)
      ++b2;
    else if (b2 > b1)
      ++b1;
    B = 1 + abs(b1 - b2);
  }
  long long ans = max(A, B);
  cout << ans << endl;
  return 0;
}
