h, w = map(int, input().split()) a, b = map(int, input().split()) c, d = map(int, input().split()) print(abs(a - c) + abs(b - d))