#include <bits/stdc++.h>
int getagroup(int x, int y, int num);
int getbgroup(int x, int y, int num);
int main(void) {
  int a, b, x1, x2, y1, y2;
  int ga1, ga2, gb1, gb2;
  int difa, difb, ans;
  scanf("%d %d %d %d %d %d", &a, &b, &x1, &y1, &x2, &y2);
  ga1 = getagroup(x1, y1, a);
  ga2 = getagroup(x2, y2, a);
  gb1 = getbgroup(x1, y1, b);
  gb2 = getbgroup(x2, y2, b);
  difa = (((ga1 - ga2) < 0) ? (-(ga1 - ga2)) : (ga1 - ga2));
  difb = (((gb1 - gb2) < 0) ? (-(gb1 - gb2)) : (gb1 - gb2));
  ans = (((difa) > (difb)) ? (difa) : (difb));
  printf("%d\n", (((difa) > (difb)) ? (difa) : (difb)));
  return 0;
}
int getagroup(int x, int y, int num) {
  int n;
  n = x + y;
  if (n >= 0)
    n /= (2 * num);
  else {
    n /= (2 * num);
    n--;
  }
  return n;
}
int getbgroup(int x, int y, int num) {
  int n;
  n = x - y;
  if (n >= 0)
    n /= (2 * num);
  else {
    n /= (2 * num);
    n--;
  }
  return n;
}
