#include<bits/stdc++.h>
using namespace std;
int main()
{
int k;
int count=0;
int count1=0;
cin>>k;
string s;
cin>>s;
for(int i=0;i<s.length();i++)
{
if(s[i]==‘a’)
count1++;
else
count++;
}
if(count>count1)
{
if(count1>k)
cout<<count+k;
else
cout<<count+count1;
}
else
{
if(count>k)
cout<<count1+k;
else
cout<<count+count1;
}
}