#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;

  vector<ll> h(n);
  vector<ll> w(m);
  for (auto &x : h)
    cin >> x;
  for (auto &x : w)
    cin >> x;

  sort(h.begin(), h.end());

  vector<ll> even(n + 2);
  vector<ll> odd(n + 2);

  for (int i = 0; i < n; i += 2)
    even[i + 2] = even[i] + h[i + 1] - h[i];
  for (int i = 1; i < n; i += 2)
    odd[i + 2] = odd[i] + h[i + 1] - h[i];

  ll ans = 1e18;
  for (auto x : w) {
    int i = distance(h.begin(), upper_bound(h.begin(), h.end(), x));

    ll cur = 0;
    if (i % 2 == 0) {
      cur += even[i];
      cur += h[i] - x;
      cur += odd[n] - odd[i + 1];
    } else {
      cur += even[i - 1];
      cur += x - h[i - 1];
      cur += odd[n] - odd[i];
    }
    ans = min(ans, cur);
  }

  cout << ans << endl;

  return 0;
}

#include <bits/stdc++.h>

typedef long long LL;

const int MAXN = 2e5 + 10;

int n, m, tot;
int a[MAXN], b[MAXN];
LL pre[MAXN * 2], suf[MAXN * 2];
struct Node { int val, id, type; } q[MAXN * 2];
struct cmz { int id, ans; } dsy[MAXN];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) scanf("%d", a + i), q[i] = (Node) { a[i], i, 1 };
	for (int i = 1; i <= m; ++i) scanf("%d", b + i), q[i + n] = (Node) { b[i], i, 2 };
	std::sort(q + 1, q + n + m + 1, [](const Node &a, const Node &b) { return a.val < b.val; });
	for (int i = 1, lst = -1; i <= n + m; ++i) {
		if (q[i].type == 1) {
			if (~lst) pre[i] = pre[i - 1] + abs(q[i].val - lst), lst = -1;
			else lst = q[i].val, pre[i] = pre[i - 1];
		} else pre[i] = pre[i - 1];
	}
	for (int i = n + m, lst = -1; i; --i) {
		if (q[i].type == 1) {
			if (~lst) suf[i] = suf[i + 1] + abs(q[i].val - lst), lst = -1;
			else lst = q[i].val, suf[i] = suf[i + 1];
		} else suf[i] = suf[i + 1];
	}
	LL ans = 2333333333333333LL;
	for (int i = 1, lst = -1; i <= n + m; ++i) {
		if (q[i].type == 2) {
			if (~lst) ans = std::min(pre[i] + suf[i] + abs(q[i].val - lst), ans), ++tot;
		} else {
			if (~lst) lst = -1;
			else lst = q[i].val;
		}
	}
	for (int i = n + m, lst = -1; i; --i) {
		if (q[i].type == 2) {
			if (~lst) ans = std::min(pre[i] + suf[i] + abs(q[i].val - lst), ans), ++tot;
		} else {
			if (~lst) lst = -1;
			else lst = q[i].val;
		}
	}
	assert(tot == m);
	printf("%lld\n", ans);
	return 0;
}