#include <bits/stdc++.h>
using namespace std;
int a, b;
bool bad(int x, int y) {
  return abs(x + y) % (2 * a) == 0 || abs(x - y) % (2 * b) == 0;
}
void reorder(int& x, int& y) {
  int xx = (x - y) / 2;
  int yy = (x + y) / 2;
  x = xx;
  y = yy;
}
void norm(int& x, int& y) {
  if ((x + y) % 2 == 0) return;
  if (!bad(x + 1, y))
    x++;
  else if (!bad(x - 1, y))
    x--;
  else if (!bad(x, y + 1))
    y++;
  else if (!bad(x, y - 1))
    y--;
}
int torect(int x, int a) {
  if (x <= 0)
    return x / a;
  else
    return x / a + 1;
}
int main() {
  int x1, y1, x2, y2;
  cin >> a >> b >> x1 >> y1 >> x2 >> y2;
  norm(x1, y1);
  norm(x2, y2);
  reorder(x1, y1);
  reorder(x2, y2);
  x1 = torect(x1, b);
  x2 = torect(x2, b);
  y1 = torect(y1, a);
  y2 = torect(y2, a);
  int dx = abs(x1 - x2);
  int dy = abs(y1 - y2);
  int ans = max(dx, dy);
  cout << ans << '\n';
  return 0;
}
