#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#define md
#define ll long long
#define inf (int) 1e9
#define eps 1e-8
#define N 500010
using namespace std;
struct cmp
{
bool operator () (int a,int b) { return a<b;}
};
priority_queue<int,vector<int>,cmp> q;
struct power{int x,ty;}p[N*2];
int ans[N];bool cmp1(power a,power b) { return a.x==b.x?a.ty<b.ty:a.x<b.x; }
bool cmp2(int a,int b){ return a>b;}
int main()
{
int n,k;
scanf("%d%d",&n,&k); ll sum=0;
for (int i=1;i<=n;i++)
{
scanf("%d",&p[i].x); p[i].ty=1;
}
for (int i=1;i<=n;i++)
{
scanf("%d",&p[i+n].x); p[i+n].ty=0; sum+=p[i+n].x;
}
sort(p+1,p+2*n+1,cmp1);
int tot=0;
for (int i=1;i<=2*n;i++)
{
if (p[i].ty==0) q.push(p[i].x);
else
{
if (q.empty()) continue;
int x=q.top(); q.pop(); //printf("pair %d %d\n",p[i].x,x);
ans[++tot]=p[i].x-x;
}
}
int sz=q.size(); //printf("sz: %d\n",sz);
if (sz>k) { printf("NIE\n"); return 0;}
else
{
if (tot) sort(ans+1,ans+tot+1,cmp2);
k-=sz;
for (int i=k+1;i<=tot;i++) sum+=ans[i];
}
printf("%lld\n",sum);
return 0;
}