z2106007726 @ 2022-03-24 21:02:54
m,n =map(int,input().split(" "))
school = list(map(int,input().split(" ")))
score = list(map(int,input().split(" ")))
school = sorted(school)
sum = 0
for x in score:
l,r = 0,len(school)-1
while l<r:
mid = (l+r)//2
if x<=school[mid]:
r = mid
else:
l = mid+1
sum += min(abs(x-school[l]),abs(x-school[l-1]))
print(sum)