program cut;
var
n,m,i,j,k,feiyong,times,jishua,jishub:longint;
a,b:array[1..2000] of longint;
c:array[1..4000] of longint;
qyn,yn:boolean;
procedure sort(l,r:longint);
var
i,j,t:longint;
begin
for i:=1 to r-1 do
for j:=i+1 to r do
if c[i]<c[j] then begin
t:=c[i];
c[i]:=c[j];
c[j]:=t;
end;
end;
begin
assign(input,'cut.in');
assign(output,'cut.out');
reset(input);
rewrite(output);
read(n,m);
for i:=1 to n-1 do read(a[i]);
for j:=1 to m-1 do read(b[j]);
for i:=1 to n-1 do c[i]:=a[i];
for j:=1 to m-1 do c[i+j]:=b[j];
sort(1,n-1+m-1);
feiyong:=c[1]; times:=1;
for i:=1 to n-1 do
if c[1]=a[i] then
begin qyn:=true;jishua:=1;break; end
else
for j:=1 to m-1 do if c[1]=b[j]
then begin qyn:=false;jishub:=1;break; end;
for i:=2 to n-1+m-1 do
begin
for k:=1 to n-1 do if c[i]=a[k]
then begin yn:=true;jishua:=jishua+1;a[k]:=0;break;end
else for j:=1 to m-1 do if c[i]=b[j]
then begin yn:=false;jishub:=jishub+1;b[j]:=0;break;end;
if yn=qyn then feiyong:=feiyong+c[i]*times
else if jishua=jishub
then feiyong:=feiyong+c[i]*(times+1)
else begin
if times>2 then times:=jishua+jishub-1
else times:=jishua+jishub;
feiyong:=feiyong+c[i]*times;
end;
end;
writeln(feiyong);
close(input);
close(output);
end.