R, C = map(int, input().split()) s1, s2 = map(int, input().split()) g1, g2 = map(int, input().split()) print(abs(s1 - g1) + abs(s2 - g2))