#include
#include <string.h>
using namespace std ;
void perfect_it(char str[], int n)
{
int len = strlen(str) ; // Sample Input is 2,abba, output shd be 4 (bbbb or aaaa)
int temp = n ;
int count = 0, count_temp = 0 ;
for (int i = 0; i < len; i++) // ababab
{
if (str[i] != str[i + 1])
{
while(temp > 0)
{
str[i + 1] = str[i] ;
temp-- ;
break ;
}
count++ ;
}
}
for (int i = 0; i < len; i++)
{
if (str[i] == str[i+1])
{
count_temp++ ;
}
}
// if (count_temp == len)
// {
// cout<<count_temp ;
// }
int res = count_temp + 1 ;
cout<<res ;
}
int main ()
{
char str[1000] ;
int n ;
cin>>n ;
cin.get() ;
cin.getline(str, 1000) ;
perfect_it(str,n) ;
return 0 ;
}