n,m=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) X=10**10 a=a+[X] b=[-X]+b+[X] p=[(v,1) for v in a]+[(v,0) for v in b] p.sort() def solve(a,r): if len(a)==0: return 0 if len(a)==1: return min(a[0],r-a[0]) return min(a[i]+r-a[i+1] for i in range(len(a)-1)) c=0 l=-X q=[] for v,f in p: if f: c+=solve(q,v-l) q=[] l=v else: q+=[v-l] print(c)