""" """ import sys from sys import stdin N,M = map(int,stdin.readline().split()) A = [-10**10] + list(map(int,stdin.readline().split())) + [10**10] B = list(map(int,stdin.readline().split())) B.reverse() ans = 0 for i in range(N+1): al = A[i] ar = A[i+1] dlis = [al] while len(B) > 0 and al <= B[-1] <= ar: dlis.append(B[-1]) del B[-1] dlis.append(ar) d2 = [] for j in range(len(dlis)-1): d2.append(dlis[j+1]-dlis[j]) #print (al,ar,d2) ma = max(d2) ans += sum(d2) - ma print (ans)