/*
    Marko Bakovic
    Muzej
*/

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>

using namespace std;

const int maxn = 3e5 + 5;

int n, m, dp[ maxn ];

char row[ maxn ];

int main()
{
    freopen( "muzej.in", "r", stdin );
    freopen( "muzej.out", "w", stdout );

    scanf( "%d %d\n", &n, &m );
    scanf( "%s", row );
    m--;

    if ( row[ 0 ] == 'a' ) dp[ 0 ] = 1;
    else dp[ 0 ] = -1;
    for ( int i = 1; i < n; i++ )
    {
        if ( row[ i ] == 'a' ) dp[ i ] = dp[ i - 1 ] + 1;
        else dp[ i ] = dp[ i - 1 ] - 1;
    }

    int idx = n - 1, cntA = 0, cntB = 0;
    if ( row[ idx ] == 'a' ) cntA++;
    else cntB++;
    while ( idx && ( idx > m || cntA < cntB ) )
    {
        idx--;
        if ( row[ idx ] == 'a' ) cntA++;
        else cntB++;
    }
    while ( idx && cntB > cntA )
    {
        idx--;
        if ( row[ idx ] == 'a' ) cntA++;
        else cntB++;
    }
    while ( idx && cntA > cntB && ( row[ idx - 1 ] == 'b' || dp[ idx - 1 ] < 0 ) )
    {
        idx--;
        if ( row[ idx ] == 'a' ) cntA++;
        else cntB++;
    }


    if ( ! idx )
    {
        printf( "0\n" );
        return 0;
    }

    idx--;
    cntA = 0, cntB = 0;
    int solution = 0;
    while ( idx >= 0 )
    {
        if ( row[ idx ] == 'a' ) cntA++;
        else cntB++;
        if ( cntA >= cntB && ( ! idx || dp[ idx - 1 ] >= 0 ) )
        {
            solution++;
            cntA = 0;
            cntB = 0;
        }
        idx--;
    }

    printf( "%d\n", solution );

    return 0;
}
