#include<bits/stdc++.h>
using namespace std;
long const mod = 1e9+7;
int main(){
    long n,m;
    cin >> n >> m;
    vector<long>h(n);
    vector<long>w(m);
    for(int i=0;i<n;i++)cin >> h[i];
    for(int i=0;i<m;i++)cin >> w[i];
    sort(h.begin(),h.end());
    sort(w.begin(),w.end());
    
    vector<long>guki(n);
    guki[0] = -h[0];
    int a = -1;
    for(int i=1;i<n;i++){
        a *= -1;
        guki[i] = guki[i-1] + a*h[i];
    }

    long ans = 1LL << 60;
    for(int i=0;i<m;i++){
        long tmp = 0;
        int cnt = upper_bound(h.begin(),h.end(), w[i]) - h.begin();
        if(cnt % 2 == 0){
            if(cnt != 0)tmp += guki[cnt-1];
            tmp -= w[i];
            
        }else{
            tmp += guki[cnt - 1];
            tmp += w[i];
        }

        if(cnt == 0){
                tmp -= guki[n-1];
        }else{
                tmp -= (guki[n-1] - guki[cnt-1]);
        }
        ans = min(ans, tmp);
    
    }
    cout << ans << endl;
}
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10;
long long n, m, Num, a[maxn], b[maxn], cnt[maxn * 2], lstt[maxn * 2], ans = 1e18;
struct My {
	long long val, pos, kkk;
	inline My() {}
	inline My(long long val, long long pos, long long kkk) : val(val), pos(pos), kkk(kkk) {}
} q[maxn * 2];
inline bool comp(const My &x, const My &y) {
	return x.val < y.val;
}
int main() {
	scanf("%lld%lld", &n, &m);
	for (long long i = 1; i <= n; ++i) {
		scanf("%lld", &a[i]);
		q[i] = My(a[i], i, 1);
	}
	for (long long i = 1; i <= m; ++i) {
		scanf("%lld", &b[i]);
		q[i + n] = My(b[i], i, 2);
	}
	
	
	
	
	
	sort(q + 1, q + n + m + 1, comp);
	
	
	for (long long i = 1, lnk = -1; i <= n + m; ++i) {
		if (q[i].kkk == 1) {
			if (lnk != -1) {
				cnt[i] = cnt[i - 1] + abs(q[i].val - lnk); 
				lnk = -1;
			}
			else {
				lnk = q[i].val; cnt[i] = cnt[i - 1];
			}
		} else cnt[i] = cnt[i - 1];
	}
	
	
	for (long long i = n + m, lnk = -1; i; --i) {
		if (q[i].kkk == 1) {
			if (lnk != -1) {
				lstt[i] = lstt[i + 1] + abs(q[i].val - lnk);
				lnk = -1;
			}
			else lnk = q[i].val, lstt[i] = lstt[i + 1];
		} else lstt[i] = lstt[i + 1];
	}
	
	
	
	
	for (long long i = 1, lnk = -1; i <= n + m; ++i) {
		if (q[i].kkk == 2) {
			if (lnk != -1) {
				ans = min(cnt[i] + lstt[i] + abs(q[i].val - lnk), ans);
				++Num;
			}
		} else {
			
			
			
			if (lnk != -1) lnk = -1;
			else lnk = q[i].val;
		}
	}
	
	for (long long i = n + m, lnk = -1; i; --i) {
		if (q[i].kkk == 2) {
			if (lnk != -1) {
				ans = min(cnt[i] + lstt[i] + abs(q[i].val - lnk), ans);
				++Num;
			}
		} else {
			if (lnk != -1) lnk = -1; else lnk = q[i].val;
		}
	}
	
	printf("%lld\n", ans);
	return 0;
}