#include <bits/stdc++.h>
using namespace std;
long long int a[1000000], b[1000000], c[1000000];
long long int pa[1000000], pb[1000000];
int main() {
  long long int n, m, i, j, k, l1 = 0, l2 = 0, ans;
  cin >> n >> m;
  for (i = 0; i < n; i++) cin >> b[i];
  for (i = 0; i < m; i++) cin >> a[i];
  sort(a, a + m);
  sort(b, b + n);
  j = 0;
  for (i = 0; i < m; i++) {
    l1 += a[i] - a[0];
    if (i > 0) pa[i] = pa[i - 1] + (a[i] - a[i - 1]) * j;
    while (j < n && b[j] < a[i]) pa[i] += a[i] - b[j++];
  }
  ans = pa[0] + l1;
  for (i = 1; i < m; i++) {
    l1 -= ((a[i] - a[i - 1]) * (m - i));
    pa[i] += l1;
    ans = min(ans, pa[i]);
  }
  j = m - 1;
  for (i = n - 1; i >= 0; i--) {
    l2 += b[n - 1] - b[i];
    if (i < n - 1) pb[i] = pb[i + 1] + (b[i + 1] - b[i]) * (m - 1 - j);
    while (j >= 0 && a[j] > b[i]) pb[i] += a[j--] - b[i];
  }
  ans = min(ans, pb[n - 1] + l2);
  for (i = n - 2; i >= 0; i--) {
    l2 -= ((b[i + 1] - b[i]) * (i + 1));
    pb[i] += l2;
    ans = min(ans, pb[i]);
  }
  cout << ans;
  return 0;
}
