#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, x1, y1, x2, y2;
  cin >> a >> b;
  cin >> x1 >> y1;
  cin >> x2 >> y2;
  long long lo, hi, mi;
  lo = -1000000000;
  hi = 1000000000;
  while (lo < hi) {
    mi = floor((lo + hi) / 2.0);
    if (y1 <= 2 * a * mi - x1)
      hi = mi;
    else
      lo = mi + 1;
  }
  int r1 = lo;
  lo = -1000000000;
  hi = 1000000000;
  while (lo < hi) {
    mi = floor((lo + hi) / 2.0);
    if (y2 <= 2 * a * mi - x2)
      hi = mi;
    else
      lo = mi + 1;
  }
  int r2 = lo;
  lo = -1000000000;
  hi = 1000000000;
  int it = 0;
  while (lo < hi && it < 15) {
    mi = floor((lo + hi) / 2.0);
    if (y1 >= x1 - 2 * b * mi)
      hi = mi;
    else
      lo = mi + 1;
  }
  int c1 = lo;
  lo = -1000000000;
  hi = 1000000000;
  it = 0;
  while (lo < hi && it < 15) {
    mi = floor((lo + hi) / 2.0);
    if (y2 >= x2 - 2 * b * mi)
      hi = mi;
    else
      lo = mi + 1;
  }
  int c2 = lo;
  int r = abs(r1 - r2), c = abs(c1 - c2);
  cout << r + c - min(r, c) << endl;
  return 0;
}
