#include <bits/stdc++.h>
//#include <atcoder/all.hpp>

using namespace std;
//using namespace atcoder;

#define all(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define PA pair<int, int>
typedef long long ll;
#define rep(i, z, n) for(int i = z; i < n; i++)
//const ll INF = 1e9;
const ll INF = 1000000007;
//const ll MOD = 9223372036854775807;
//const ll MOD2 = 998244353;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N, M;
vector<int> H(200001, -1), W(200001, -1);
vector<int> sum1(100000, -1);
vector<int> sum2(100000, -1);

ll cal(int tea, int posi){
    ll ans = abs(tea - H[2 * posi]);
    //cout << posi << " " << ans << endl;
    if(posi >= 1) ans += sum1[posi - 1];
    //cout << ans << endl;
    if(posi < (N - 1)/2) ans += sum2[posi];
    //cout << ans << endl;
    //cout << endl;
    return ans;
}
int main(){
    cin >> N >> M;
    H.resize(N);
    W.resize(M);
    rep(i, 0, N) cin >> H[i];
    rep(i, 0 ,M) cin >> W[i];
    sort(all(H));
    sort(all(W));
    
    rep(i, 0, (N - 3) / 2 + 1){
        sum1[i] = (H[2 * i + 1] - H[2 * i]);
        sum2[i] = (H[2 * i + 2] - H[2 * i + 1]);
        if(i >= 1){
            sum1[i] += sum1[i - 1];
        }
    }
    for(int i = (N - 3) / 2; i >= 1; i--){
        sum2[i - 1] += sum2[i];
    }
    
    int position = 0;
    ll ans = INF;
    rep(i, 0, M){
        while((W[i] > H[position]) && (position < N)){
            position++;
        }
        //cout << cal(W[i], position/2) << " " << position << endl;
        ans = min(ans, cal(W[i], position/2));
    }
    rep(i, 0 ,(N - 1)/2){
        //cout << i << " " << sum2[i] << endl;;
    }
    cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;




















   cin>>n;
















   int k;
   cin>>k;



















     long long int s(0);
    for(int i=1;i<=n; ++i)
     {

           for(int j=1;j<=k; ++j)
           {
                s+=100*i+j;
           }
     }
      cout<<s;
     //else

}
