#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, x1, y1, x2, y2;
  cin >> a >> b >> x1 >> y1 >> x2 >> y2;
  a *= 2;
  b *= 2;
  cout << max(abs((x1 + y1 + 0x7fffffff * a) / a -
                  (x2 + y2 + 0x7fffffff * a) / a),
              abs((x1 - y1 + 0x7fffffff * b) / b -
                  (x2 - y2 + 0x7fffffff * b) / b))
       << endl;
  return 0;
}
