#include<bits/stdc++.h>
#define str to_string
using namespace std;
using ll=long long;
const int MAX=1e5+1;
int n,m,a[MAX],b[MAX];
bool check(int mid,int tar){
return a[mid]<tar;
}
int Reason(int tar){
int l=1,r=n;
while(l<=r){
int mid=(l+r)>>1;
if(check(mid,tar))l=mid+1;
else r=mid-1;
}
return min(abs(a[l-1]-tar),abs(a[l]-tar));
}
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=m;i++)cin>>b[i];
sort(a+1,a+n+1);
int ans=0;
for(int i=1;i<=m;i++)ans+=Reason(b[i]);
cout<<ans<<'\n';
return 0;
}