x, y = input().split()
x, y = int(x) - 1, int(y) - 1

sx, sy = input().split()
sx, sy = int(sx), int(sy)

wx, wy = input().split()
wx, wy = int(wx), int(wy)

delta_x = (x - sx) + wx
delta_y = (y - sy) + wy

if abs(wx - sx) < delta_x:
    delta_x = abs(wx - sx)
if abs(wy - sy) < delta_y:
    delta_y = abs(wy - sy)
    
print(delta_x + delta_y)