r,c = [int(i) for i in input().split()] a,b = [int(i) for i in input().split()] c,d = [int(i) for i in input().split()] print(abs(a-c)+abs(b-d))