#include<bits/stdc++.h>
using namespace std;
long long a[100010],b[100010];
int main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];
}
sort(a+1,a+1+n);
for(int i=1;i<=m;i++){
cin>>b[i];
}
int js=0;
for(int i=1;i<=m;i++){
int l=1,r=n;
while(l<=r){
int mid=l+(r-l)/2;
if(a[mid]<=b[i]){
l=mid+1;
}
else{
r=mid-1;
}
}
if(b[i]<=a[1]){
js+=a[1]-b[i];
}
else{
js+=min(abs(a[l]-b[i]),abs(a[l-1]-b[i]));
}
}
cout<<js;
}
#1没过