#include <bits/stdc++.h>
using namespace std;
long long int powmod(long long int a, int b, int n) {
  long long int rm = 1;
  while (b) {
    if (b % 2) {
      rm = (rm * a) % n;
    }
    a = (a * a) % n;
    b /= 2;
  }
  return rm;
}
int main() {
  long long int a, b, x1, x2, y1, y2;
  long long int ans = 0;
  cin >> a >> b >> x1 >> y1 >> x2 >> y2;
  long long int a2 = a * 2, b2 = b * 2;
  long long int r = ((x1 + y1) % a2 + a2) % a2;
  long long int ynew1 = y1 - r;
  long long int v1 = (x1 + ynew1) / a2;
  r = ((x2 + y2) % a2 + a2) % a2;
  ynew1 = y2 - r;
  long long int v2 = (x2 + ynew1) / a2;
  long long int bl1 = abs(v2 - v1);
  r = ((x1 - y1) % (2 * b) + b2) % b2;
  long long int xnew1 = x1 - r;
  v1 = (xnew1 - y1) / (2 * b);
  r = ((x2 - y2) % b2 + b2) % b2;
  xnew1 = x2 - r;
  v2 = (xnew1 - y2) / b2;
  long long int bl2 = abs(v2 - v1);
  if (bl1 > bl2)
    cout << bl1 << endl;
  else
    cout << bl2 << endl;
  return 0;
}
