#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN   
#define inf INT_MAX
#define linf LLONG_MAX
#define lninf LLONG_MIN   
const int mod = 1e9 + 7;
const int N = 1e6 + 4;

int solve()
{
	int n, m; scn(n); scn(m);

	map<int, int> ma;

	rep(i, 0, n)
	{
		int val; scn(val); ma[val]++;
	}

	rep(i, 0, m)
	{
		int val; scn(val); ma[val]++;
	}

	for(auto it: ma)
	if(it.S == 1)
	printf("%d ", it.F);

	return 0;
}

int main()                  
{
	int t = 1; //scn(t);

	while(t--)
	{
		solve();
	}

    return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define io ios::sync_with_stdio(false); cin.tie(0)

int main()
{
    io;
    int n, k; cin >> n >> k;
    vector<int> a(n);
    vector<int> cnt(n, 0);
    rep(i, n) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    int res = 0;
    rep(i, k) {
        rep(j, n) {
            if (cnt[j] == 0) {
                res += j;
                break;
            }
            cnt[j]--;
        }
    }
    cout << res << endl;
    return 0;
}