#include using namespace std; int main() { int r, c; cin >> r >> c; int sy, sx, gy, gx; cin >> sy >> sx >> gy >> gx; cout << abs(sy - gy) + abs(sx - gx) << endl; return 0; }