#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
//typedef long long ll;
const int M_ans = 0x3f3f3f3f;
const int M = 2e5 + 10;
int h[M], w[M], qsm[M], hsm[M];
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> h[i];
    for (int i = 1; i <= m; i++)
        cin >> w[i];
    sort(h + 1, h + 1 + n);
    sort(w + 1, w + 1 + m);
    for (int i = 2; i <= n; i += 2)
        qsm[i] = qsm[i - 2] + h[i] - h[i - 1];
    for (int i = n - 1; i >= 1; i -= 2)
        hsm[i] = hsm[i + 2] + h[i + 1] - h[i];
    int ans = M_ans;
    for (int i = 1; i <= m; i++)
    {
        int p = lower_bound(h + 1, h + 1 + n, w[i]) - h;
        if (p % 2 == 0)
            p--;
        ans = min(ans, qsm[p - 1] + hsm[p + 1] + abs(w[i] - h[p]));
    }
    cout << ans << endl;
    return 0;
}
#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> plli;
typedef vector< vi > vvi ;
typedef vector< vlli > vvlli  ;
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define flli(i,a,b) for(long long int i=a;i<=b;i++)
#define bi(i,a,b) for(int i=a;i>=b;i--)
#define blli(i,a,b) for(long long int i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pi 2*acos(0.0)
#define pb push_back
#define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
#define present(v,num) (v.find(num)!=v.end())
#define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
#define pq priority_queue
#define mp make_pair
const int inf=INT_MAX;
const lli INF =LLONG_MAX;
const lli mod = 1e9+7;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast;
    lli n,m;cin>>n>>m;
    vlli h(n);
    vlli w(m);
    flli(i,0,n-1)cin>>h[i];
    flli(i,0,m-1)cin>>w[i];
    sort(all(h));
    sort(all(w));
    vlli forans(n);
    vlli bacans(n);
    lli ind=1;
    lli last=0;
    while(ind<n)
    {
    	last+=h[ind]-h[ind-1];
    	forans[ind]=last;
    	ind+=2;
    }
    ind=n-2;
    last=0;
    while(ind>=0)
    {
    	last+=h[ind+1]-h[ind];
    	bacans[ind]=last;
    	ind-=2;
    }
    lli ans=INF;
    ind=-1;
    flli(i,0,m-1)
    {
    	if(w[i]<=h[0])ind=i;
    }
    if(ind!=-1)
    {
    	lli nexti=0;
    	if(1<=n-2)nexti=bacans[1];
    	ans=min(ans,-w[ind]+h[0]+nexti);
    }
    flli(i,0,n-1)
    {
    	//will put after h[i];
    	if(h[i]>w[m-1])continue;
    	auto var=lower_bound(all(w),h[i]);
    	if(i%2==0)
    	{
    		lli nexti=0;
    		lli prev=0;
    		if(i+1<n)nexti=bacans[i+1];
    		if(i-1>=0)prev=forans[i-1];
    		ans=min(ans,*var-h[i]+prev+nexti);
    	}
    	else 
    	{
    		lli nexti=0;
    		lli prev=0;
    		prev=forans[i];
    		if(i+2<n)nexti=bacans[i+2];
    		ans=min(ans,abs(*var-h[i+1])+prev+nexti);
    	}
    }
    cout<<ans;
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}