#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
int a, b, x1, ___y1, x2, y2;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> a >> b >> x1 >> ___y1 >> x2 >> y2;
  int x = x1, y = ___y1;
  x1 = x + y;
  ___y1 = x - y;
  x = x2, y = y2;
  x2 = x + y;
  y2 = x - y;
  a <<= 1;
  b <<= 1;
  x1 = x1 / a + (x1 > 0);
  x2 = x2 / a + (x2 > 0);
  ___y1 = ___y1 / b + (___y1 > 0);
  y2 = y2 / b + (y2 > 0);
  cout << max(abs(x1 - x2), abs(___y1 - y2));
  return 0;
}
