/*
Author: SJ
general
1.shuzu buyao kai xiaole
2.0 1 zhe liangge tepan
3.dfs jide biaoji qidian
str
1.yongle s.substr(), jide kanyixiashibushikeyi yigeyige shuchu
think twice, code once.
*/
#include <bits/stdc++.h>
const int N = 1e5 + 10;
const int INF = 1e9;
using ll = long long;
int n, m, a[100010];
ll ans;
void bsearch(int x) {
int l = 0, r = n - 1, mark = 0;
while (l <= r) {
int mid = l + r >> 1;
if (a[mid] >= x) {
mark = mid;
r = mid - 1;
} else l = mid + 1;
}
int y = std::abs(a[mark] - x), z = std::abs(a[mark - 1] - x);
ans += std::min(y, z);
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cin >> n >> m;
for (int i = 0; i < n; i++) std::cin >> a[i];
std::sort(a, a + n);
for (int i = 0; i < m; i++) {
int b;
std::cin >> b;
bsearch(b);
}
std::cout << ans;
return 0;
}