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