#include <bits/stdc++.h>
using namespace std;
int inf = 1000000009;
int findB(int x, int y, int a) {
  long long low = -inf;
  long long high = inf;
  long long val, mid;
  while (low < high) {
    mid = low + (high - low) / 2;
    val = x - y - 2 * a * mid;
    if (val < 0) {
      high = mid;
    } else
      low = mid + 1;
  }
  return low;
}
int findA(int x, int y, int a) {
  long long low = -inf;
  long long high = inf;
  long long val, mid;
  while (low < high) {
    mid = low + (high - low) / 2;
    val = x + y - 2 * a * mid;
    if (val < 0) {
      high = mid;
    } else
      low = mid + 1;
  }
  return low;
}
int main() {
  int a, b, x1, y1, x2, y2;
  int a1, a2, b1, b2, ret;
  cin >> a >> b >> x1 >> y1 >> x2 >> y2;
  a1 = findA(x1, y1, a);
  a2 = findA(x2, y2, a);
  b1 = findB(x1, y1, b);
  b2 = findB(x2, y2, b);
  ret = max(abs(a1 - a2), abs(b1 - b2));
  cout << ret;
  return 0;
}
