#include <bits/stdc++.h>
using namespace std;
int A, B;
int nearestMinus(long long i1, long long j1, long long i2, long long j2) {
  long long con1 = (i1 - j1) % B;
  long long con2 = (i2 - j2) % B;
  if (con2 < 0) con2 += B;
  if (con1 <= 0)
    con1 *= -1;
  else
    con1 = B - con1;
  long long diff = abs((i2 - j2 - con2) - (i1 - j1 + con1));
  return (diff / B) + 1LL;
}
int getMinus(int i1, int j1, int i2, int j2) {
  int v1 = nearestMinus(i1, j1, i2, j2);
  int v2 = nearestMinus(i2, j2, i1, j1);
  if (v1 == 2 && v2 == 2) return 0;
  return min(v1, v2);
}
int nearestPlus(long long i1, long long j1, long long i2, long long j2) {
  long long con1 = (i1 + j1) % A;
  long long con2 = (i2 + j2) % A;
  if (con2 < 0) con2 += A;
  if (con1 <= 0)
    con1 *= -1;
  else
    con1 = A - con1;
  long long diff = abs((i2 + j2 - con2) - (i1 + j1 + con1));
  return (diff / A) + 1LL;
}
int getPlus(int i1, int j1, int i2, int j2) {
  int v1 = nearestPlus(i1, j1, i2, j2);
  int v2 = nearestPlus(i2, j2, i1, j1);
  if (v1 == 2 && v2 == 2) return 0;
  return min(v1, v2);
}
int main() {
  FILE *in = stdin;
  int c, c2;
  int i1, j1, i2, j2;
  fscanf(in, "%d%d%d%d%d%d", &A, &B, &i1, &j1, &i2, &j2);
  A += A;
  B += B;
  int ret = getPlus(i1, j1, i2, j2);
  int ret2 = getMinus(i1, j1, i2, j2);
  printf("%d\n", max(ret, ret2));
  return 0;
}
