from bisect import bisect_left m, n = map(int, input().split()) b = list(map(int, input().split())) a = list(map(int, input().split())) c = a + b c.sort() ans = max(c) - min(c) + 1 - m for i in range(m - 1): l = bisect_left(c, b[i]) r = bisect_left(c, b[i + 1]) res = 0 for j in range(l, r): res = max(res, c[j + 1] - c[j] - 1) ans -= res print(ans)