#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("input.in","r",stdin);
    int n,x;
    cin>>n>>x;
    while(n--){
        char ch;
        cin>>ch;
        if(ch=='o') x++;
        else x=max(0,x-1);
    }
    cout<<x<<endl;
}

#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define pdd pair<double,double>
#define pii pair<int,int>
#define pll pair<LL,LL>
#define mp make_pair
#define LL long long
#define ULL unsigned long long
#define sqr(x) ((x)*(x))
#define pi acosl(-1)
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
using namespace std;
#define Point pdd
#define Polygon vector<Point>
#define Line pair<Point,Point>
#define rank Rank
bool solve(){
    int n,k;
    scanf("%d %d",&n,&k);
    int cnt[300005];
    fill(cnt,cnt+n+1,0);
    for(int i = 0;i<n;i++){
        int x;
        scanf("%d",&x);
        cnt[x]++;
    }
    int last=k;
    LL ans=0;
    for(int i = 0;i<n;i++){
        ans+=max(last-cnt[i],0)*i;
        last=min(last,cnt[i]);
    }
    printf("%lld\n",ans);
    return true;
}
int main(){
    int t=1;//00000;
  //  scanf("%d",&t);
    while(t--)solve();
}
/*
1 4 10100
1 6 1010100
1 8 101010100
1 y 10100  (y+1)  y/2
2 5 1100100
2 6 11001100
2 7 110011000
2 8 1100110000
2 9 11001100100
*/