#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF = __LONG_LONG_MAX__;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i

signed main()
{
   int n,m;
   cin>>n>>m;
   vector<int> H(n);
   vector<int> W(m);
   for(auto &h:H) cin>>h;
   for(auto &w:W) cin>>w;
   sort(H.begin(),H.end());
   vector<int> sum(n+1,0);
   for(int i=0;i<n;i++){
    if(i&1)
        sum[i+1]=sum[i]+H[i];
    else
        sum[i+1]=sum[i]-H[i];
    }
    int res=INF;
    for(auto w:W){
        int index=lower_bound(H.begin(),H.end(),w)-H.begin();
        if(index&1)
            index--;
        int mid=abs(H[index]-w);
        int top=(-1)*(sum[n]-sum[index+1]);
        int bottom=sum[index];
        res=min(res,top+mid+bottom);
    }
    cout<<res<<endl;
    return 0;
}
 #include <bits/stdc++.h>
#define ll         long long int 
#define pb         push_back
#define umap       unordered_map
#define mod        1000000007
#define all(x)     (x).begin(), (x).end()
#define rall(x)    (x).rbegin(), (x).rend()
#define MN(a,b,c)  min(a,min(b,c))
#define MX(a,b,c)  max(a,max(b,c))
#define pr1         pair<ll,ll>
#define F          first
#define S          second
#define mP         make_pair
#define f(i,n)     for(ll i=0;i<n;i++)
#define f1(i,x,y)  for(ll i=x;i<=y;i++)
#define f2(i,x,y)  for(ll i=x;i>=y;i--)
#define yes        cout<<"YES"<<"\n"
#define no         cout<<"NO"<<"\n"
#define modsum(a,b)  ((a%mod)+(b%mod))%mod
#define modpro(a,b)  ((a%mod)*(b%mod))%mod
#define moddif(a,b)  ((a%mod)-(b%mod)+mod)%mod
//__builtin_popcount(x)
//__builtin_parity(x)   =(number of set bits)%2
//__builtin_clz(x)      to count the number of leading  zeroes 
//__builtin_ctz(x)      to count the number of trailing zeroes 
//__gcd(a,b)
using namespace std;
ll Fact(ll x)
{
    ll y=1;
    for(ll i=1;i<=x;i++){y=modpro(y,i);}
    return y;
}
ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=((result%M) * (x%M))%M;
        x=((x%M)*(x%M))%M;
        n=n/2;
    }
    return result;
}
ll binaryExponentiation(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=result * x;
        x=x*x;
        n=n/2;
    }
    return result;
}
ll pow1(ll x,ll y)
{
    ll z=1;
    while(y--){z=z*x;}
    return z;
}
bool isprime(ll n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
 
    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;
 
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
 
    return true;
}
ll check(ll x)
{
    ll y=1,z=0;
    while(x>y){y*=2;z++;}
    if(x!=y){z--;}
    return z;
}
// Returns n^(-1) mod p 
unsigned long long modInverse(unsigned long long n, int p) 
{ 
    return modularExponentiation(n, p - 2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
unsigned long long nCrModPFermat(unsigned long long n, 
                                 int r, int p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    unsigned long long fac[n + 1]; 
    fac[0] = 1; 
    for (int i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
} 
ll modInverse(ll A,ll M)
{
    return modularExponentiation(A,M-2,M);
}
bool cmp(pair<ll,ll> a, pair<ll,ll> b)
{
    if(a.F==b.F)
        return a.S<b.S;
    else 
        return a.F<b.F;
}
int main()
{
 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 ll n,m;
 cin>>n>>m;
 vector <ll> a(n),b(m);
 f(i,n) cin>>a[i];
 f(i,m) cin>>b[i];
 
 sort(all(a));
 sort(all(b));
 
 ll mn=1e18;
 
 vector <ll> start(n),end(n);
 f(i,n)
 {
     if(i%2==1) start[i]=start[i-1]+abs(a[i]-a[i-1]);
     else 
          {
              if(i==0) start[i]=0;
              else     start[i]=start[i-1];
          }
 }
 for(ll i=n-1;i>=0;i--)
 {
     ll j=n-1-i;
     if(j%2==1) end[i]=end[i+1]+abs(a[i]-a[i+1]);
     else
     {
         if(j==0) end[i]=0;
         else     end[i]=end[i+1];
     }
 }
 f(i,m)
 {
     ll y=(upper_bound(a.begin(),a.end(),b[i])-a.begin());
      //cout<<y<<"\n";
     if(y%2==1)
     {
         ll val=abs(b[i]-a[y-1]);
         if((y-2)>=0) val+=start[y-2];
         if(y<n)  val+=end[y];
         //cout<<i<<' '<<val<<"\n";
         mn=min(mn,val);
     }
     else
     {
         ll val=abs(b[i]-a[y]);
         if((y-1)>=0) val+=start[y-1];
         if((y+1)<n)  val+=end[y+1];
         //cout<<i<<' '<<val<<"\n";
         mn=min(mn,val);
     }
 }
 cout<<mn<<"\n";
}

 