#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
using namespace std;
signed main()
{
Fast
int n,m;
cin>>n>>m;
int mtr[n],mac[m];
for(int i=0;i<n;i++) cin>>mtr[i];
for(int j=0;j<m;j++) cin>>mac[j];
sort(mtr,mtr+n,std::greater<int>());
sort(mac,mac+m,std::greater<int>());
int ans = 0,key = 0;
for(int k=0;k<n;k++)
{
if (mtr[k]<=mac[key])
{
key++;
ans += mtr[k];
if (key == m)
break;
}
}
cout<<ans;
}