w,h = list(map(int,input().split()))

a = [10**18]+[int(eval(input())) for i in range(w)]

b = [10**18]+[int(eval(input())) for i in range(h)]

a.sort(reverse=True)

b.sort(reverse=True)

ans = 0

while len(a)>1 or len(b)>1:

  if a[-1]<b[-1]:

    ans += a[-1]*len(b)

    a.pop()

  else:

    ans += b[-1]*len(a)

    b.pop()

print(ans)
import sys

input = sys.stdin.readline

w,h = list(map(int,input().split()))

a = [10**18]+[int(eval(input())) for i in range(w)]

b = [10**18]+[int(eval(input())) for i in range(h)]

a.sort(reverse=True)

b.sort(reverse=True)

ans = 0

while len(a)>1 or len(b)>1:

  if a[-1]<b[-1]:

    ans += a[-1]*len(b)

    a.pop()

  else:

    ans += b[-1]*len(a)

    b.pop()

print(ans)
w, h = list(map(int, input().split()))
a = [10**18] + [int(eval(input())) for i in range(w)]
b = [10**18] + [int(eval(input())) for i in range(h)]
a.sort(reverse=True)
b.sort(reverse=True)
ans = 0
while len(a) > 1 or len(b) > 1:
    if a[-1] < b[-1]:
        ans += a[-1] * len(b)
        a.pop()
    else:
        ans += b[-1] * len(a)
        b.pop()
print(ans)

import sys

input = sys.stdin.readline
w, h = list(map(int, input().split()))
a = [10**18] + [int(eval(input())) for i in range(w)]
b = [10**18] + [int(eval(input())) for i in range(h)]
a.sort(reverse=True)
b.sort(reverse=True)
ans = 0
while len(a) > 1 or len(b) > 1:
    if a[-1] < b[-1]:
        ans += a[-1] * len(b)
        a.pop()
    else:
        ans += b[-1] * len(a)
        b.pop()
print(ans)

+import sys + +input = sys.stdin.readline