#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5, M = 1e6 + 5, C = 1e3 + 5, MOD = 1e9 + 7,
                OO = 1e9 + 5;
long long a, b, x1, x2, y_1, y2;
long long addLine(long long mul, long long x) { return mul * a - x; }
long long subLine(long long mul, long long x) { return mul * b + x; }
pair<long long, long long> getLines(long long x, long long y) {
  long long st = -OO, en = OO;
  while (st <= en) {
    long long mid = (st + en) / 2;
    if (addLine(mid, x) < y) {
      st = mid + 1;
    } else {
      en = mid - 1;
    }
  }
  pair<long long, long long> res;
  res.first = st - 1;
  st = -OO, en = OO;
  while (st <= en) {
    long long mid = (st + en) / 2;
    if (subLine(mid, x) < y) {
      st = mid + 1;
    } else {
      en = mid - 1;
    }
  }
  res.second = st - 1;
  return res;
}
int main() {
  cin.sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> a >> b >> x1 >> y_1 >> x2 >> y2;
  a *= 2;
  b *= 2;
  pair<long long, long long> pt1 = getLines(x1, y_1);
  pair<long long, long long> pt2 = getLines(x2, y2);
  long long diff1 = abs(pt1.first - pt2.first);
  long long diff2 = abs(pt1.second - pt2.second);
  cout << max(diff1, diff2) << endl;
}
