#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int gcdExtended(long long int a, long long int b, long long int* x,
                          long long int* y) {
  if (a == 0) {
    *x = 0;
    *y = 1;
    return b;
  }
  long long int x1, y1;
  long long int gcd = gcdExtended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
long long int mod = 1000000007;
long long int binpower(long long int a, long long int b) {
  long long int ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}
bool isPrime(int n) {
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) return false;
  }
  return true;
}
struct segtree {
  int sz;
  vector<int> sums;
  vector<int> mini;
  void init(int n) {
    sz = 1;
    while (sz < n) {
      sz *= 2;
    }
    sums.resize(2 * sz);
    mini.resize(2 * sz);
  }
  int single(long long int v) { return v; }
  int join(int a, int b, bool maxi = false) {
    if (maxi)
      return max(a, b);
    else
      return min(a, b);
  }
  void sett(int i, long long int v, int x, int lx, int rx) {
    if (rx - lx == 1) {
      sums[x] = single(v);
      mini[x] = single(v);
      return;
    }
    int m = (lx + rx) / 2;
    if (i < m)
      sett(i, v, 2 * x + 1, lx, m);
    else
      sett(i, v, 2 * x + 2, m, rx);
    sums[x] = join(sums[2 * x + 1], sums[2 * x + 2], true);
    mini[x] = join(mini[2 * x + 1], mini[2 * x + 2]);
  }
  void sett(int i, long long int v) { sett(i, v, 0, 0, sz); }
  int calc(int l, int r, int x, int lx, int rx) {
    if (lx >= r || l >= rx) return INT_MIN;
    if (lx >= l && rx <= r) return sums[x];
    int m = (lx + rx) / 2;
    int s1 = calc(l, r, 2 * x + 1, lx, m);
    int s2 = calc(l, r, 2 * x + 2, m, rx);
    return join(s1, s2, true);
  }
  int calcmin(int l, int r, int x, int lx, int rx) {
    if (lx >= r || l >= rx) return INT_MAX;
    if (lx >= l && rx <= r) return mini[x];
    int m = (lx + rx) / 2;
    int s1 = calcmin(l, r, 2 * x + 1, lx, m);
    int s2 = calcmin(l, r, 2 * x + 2, m, rx);
    return join(s1, s2);
  }
  int calc(int l, int r) { return calc(l, r, 0, 0, sz); }
  int calcmin(int l, int r) { return calcmin(l, r, 0, 0, sz); }
};
long long int f(long long int val, vector<long long int>& a,
                vector<long long int>& b) {
  long long int ans = 0;
  int n = a.size(), m = b.size();
  for (int i = 0; i < n; ++i) {
    if (a[i] > val) break;
    ans += abs(a[i] - val);
  }
  for (int i = 0; i < m; ++i) {
    if (b[i] < val) break;
    ans += abs(b[i] - val);
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int test = 1;
  while (test--) {
    int n, m;
    cin >> n >> m;
    vector<long long int> a(n), b(m);
    set<long long int> s;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      s.insert(a[i]);
    }
    for (int i = 0; i < m; ++i) {
      cin >> b[i];
      s.insert(b[i]);
    }
    set<long long int>::iterator it;
    vector<long long int> v;
    for (it = s.begin(); it != s.end(); ++it) {
      v.push_back(*it);
    }
    int sz = v.size();
    sort(a.begin(), a.end());
    sort(b.begin(), b.end(), greater<long long int>());
    int l = 0, r = sz;
    while (true) {
      if (r - l < 3) break;
      int m1 = l + (r - l) / 3;
      int m2 = r - (r - l) / 3;
      if (f(v[m1], a, b) < f(v[m2], a, b))
        r = m2;
      else
        l = m1;
    }
    long long int ans = 1000000000000000;
    for (int i = l; i <= r; ++i) {
      ans = min(ans, f(v[i], a, b));
    }
    cout << ans;
  }
  return 0;
}
