with open('1.input') as f:
l,r=[],[]
d=lambda a,b:[abs(a-b) for a,b in zip(sorted(a), sorted(b))]
for i in f:l.append(int(i.split()[0])),r.append(int(i.split()[1]))
print(sum(d(l,r)))