#include <bits/stdc++.h>
using namespace std;
const long long inf = 1000 * 1000 * 1000;
const int mx[5] = {0, -1, 0, 1, 0};
const int my[5] = {0, 0, -1, 0, 1};
struct pt {
  long long x, y;
};
long long a, b;
pt s, f, v, u;
pt convert(pt p) {
  long long l = -inf;
  long long r = inf;
  pt q;
  while (l < r - 1) {
    long long m = (l + r) / 2;
    if (p.y >= 2 * a * m - p.x)
      l = m;
    else
      r = m;
  }
  q.x = l;
  l = -inf;
  r = inf;
  while (l < r - 1) {
    long long m = (l + r) / 2;
    if (p.y >= 2 * b * m + p.x)
      l = m;
    else
      r = m;
  }
  q.y = l;
  return q;
}
long long dist(pt a, pt b) {
  long long dx = abs(a.x - b.x);
  long long dy = abs(a.y - b.y);
  long long d = min(dx, dy);
  dx -= d;
  dy -= d;
  return d + dx + dy;
}
int main() {
  scanf("%I64d %I64d", &a, &b);
  scanf("%I64d %I64d", &s.x, &s.y);
  scanf("%I64d %I64d", &f.x, &f.y);
  long long res = inf;
  v = convert(s);
  u = convert(f);
  res = dist(v, u);
  printf("%I64d", res);
  return 0;
}
