#include<bits/stdc++.h> using namespace std; int main(){ int h,s; cin>>h>>s; char code[105]; cin>>code; for(int i=0;i<strlen(code);i++){ if(code[i]=='u'&&s>0)s-=1; else if(code[i]=='d'&&s<h)s+=1; } cout<<s; return 0; }