#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793238462643l;
void solve();
int main() {
  solve();
  return 0;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void solve() {
  long long a, b, x1, y1, x2, y2;
  cin >> a >> b >> x1 >> y1 >> x2 >> y2;
  long long ans1, ans2;
  long long eps11 = 0, eps12 = 0, eps21 = 0, eps22 = 0;
  if (x1 + y1 < 0) eps11 = -2 * a;
  if (x2 + y2 < 0) eps12 = -2 * a;
  if (x1 - y1 < 0) eps21 = -2 * b;
  if (x2 - y2 < 0) eps22 = -2 * b;
  ans1 = (x1 + y1 + eps11) / (2 * a) - (eps12 + x2 + y2) / (2 * a);
  ans2 = (eps21 + x1 - y1) / (2 * b) - (eps22 + x2 - y2) / (2 * b);
  if (ans1 < 0) ans1 = -ans1;
  if (ans2 < 0) ans2 = -ans2;
  cout << max(ans1, ans2);
}
