#include <bits/stdc++.h>
using namespace std;
vector<int> a, b;
int n, m;
long long calc1(int f) {
  long long re = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] < f) re += f - a[i];
  }
  return re;
}
long long calc2(int f) {
  long long re = 0;
  for (int i = 0; i < m; i++) {
    if (b[i] > f) re += b[i] - f;
  }
  return re;
}
void solve() {
  cin >> n >> m;
  a.resize(n);
  b.resize(m);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int j = 0; j < m; j++) cin >> b[j];
  sort((a).begin(), (a).end());
  sort((b).begin(), (b).end());
  int l = min(a[0], b[0]);
  int r = max(a[n - 1], b[m - 1]);
  long long ans = numeric_limits<long long>::max();
  ;
  while (r - l > 3) {
    int m1 = l + (r - l) / 3;
    int m2 = r - (r - l) / 3;
    long long f1 = calc1(m1) + calc2(m1);
    long long f2 = calc1(m2) + calc2(m2);
    if (f1 > f2)
      l = m1;
    else
      r = m2;
    ans = min(ans, min(f1, f2));
  }
  for (int i = l; i < r + 1; i++) {
    long long f = calc1(i) + calc2(i);
    ans = min(ans, f);
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
