""" day 1 """
import fileinput
left = []
right = []
for line in fileinput.input():
a, b = line.split()
left.append(int(a))
right.append(int(b))
left = sorted(left)
right = sorted(right)
total = 0
for a,b in zip(left,right):
total += abs(a-b)
print(total)