#include <bits/stdc++.h>
using namespace std;
#define int long long
void read (int &x) {
    char ch = getchar(); x = 0; int f = 0;
    while (!isdigit(ch)) { if (ch == '-') f = 1; ch = getchar(); }
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    if (f) x = -x;
} const int N = 3e5 + 5;
int n, k, res, a[N], c[N];
signed main() {
    read (n), read (k);
    for (int i = 1; i <= n; ++i)
        read (a[i]), ++c[a[i]];
    int now = k;
    for (int i = 0; i <= n; ++i) {
        if (now > c[i]) res += (now - c[i]) * i, now = c[i];
    }
    printf ("%lld\n", res);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define TEZ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define vi vector<pair<ll,ll>>
#define ff first
#define ss second
#define mp map<ll,ll>
#define test ll t; cin>>t; while(t--)
#define srt(v) sort(v.begin(),v.end())
double pi=acos(-1);
const ll MOD=1000000007;
void OJ(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
}
int main(){
    TEZ;
    ll ans=0;
    string s;
    cin>>s;
    f(i,0,10000){
        vector<bool> present(10,false);
        ll x=i;
        f(j,0,4){
            present[x%10]=true;
            x/=10;
        }
        bool fl=true;
        f(i,0,s.length()){
            if(s[i]=='o' and present[i]==false)
                fl=false;
            if(s[i]=='x' and present[i]==true)
                fl=false;
        }
        ans+=fl;
    }
    cout<<ans;
}