#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3f;
long long n, m;
vector<long long> a, b;
long long func(long long k) {
  long long sum = 0;
  for (auto x : a)
    if (x < k) sum += k - x;
  for (auto y : b)
    if (y > k) sum += y - k;
  return sum;
}
long long ternary_search_min(long long l = 1, long long r = 1e9) {
  long long m1, m2;
  while (r - l > 5) {
    m1 = (2 * l + r) / 3;
    m2 = (2 * r + l) / 3;
    if (func(m2) < func(m1))
      l = m1;
    else
      r = m2;
  }
  long long mn = INF, idx;
  for (long long i = l; i <= r; i++) {
    if (func(i) < mn) mn = func(i), idx = i;
  }
  return func(idx);
}
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  long long aux;
  while (n--) cin >> aux, a.push_back(aux);
  while (m--) cin >> aux, b.push_back(aux);
  cout << ternary_search_min() << endl;
}
