#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <string>
#include <cmath>



using namespace std;




int n,i,m,k; char str[300005]; int a[300005];
bool obradjen[300005] = {false};

int main()
{
    FILE *fin, *fout;
    fin = fopen("muzej.in", "r");
    fout = fopen("muzej.out", "w");
    fscanf(fin,"%d%d", &n, &m);
    fscanf(fin,"%s", str);
    //for (i = 0; i < n; i++) printf("%c", str[i]);
    char tren = str[0]; 
    int br = 1; k = -1;
    int brA = 0;
    int brB = 0;
    if (str[0] == 'a') brA++;
    else brB++;
    for (i = 1; i < n; i++)
    {
        if (str[i] == 'a') brA++;
        else brB++;
        if (str[i] == tren) br++;
        else
        {
            tren = str[i];
            k++;
            a[k]= br;
            br = 1;
            /*if (tren == 'a') a[k].vrednost = true;
            else a[k].vrednost = false;*/
            
        } 
    }
    k++;
    a[k] = br;
    //printf("%d %d\n" , brA, brB);
    /*for (i = 0; i <= k; i++) printf("%d ", a[i]);
    printf("\n");*/
    if (str[0] == 'b') i = 0;
    else i = 1; br = 0;
    
    for (i; i <= k; i += 2)
    {
      if (a[i] == 1) 
      {
          br++;
          //printf("%d\n", br);
          //system("pause");
          brA--;
      }
      else
      {
         br += 2;
         //printf("%d\n", br);
         //system("pause");
         brA -= a[i];
      }
     }
     
     br += brA;
     
     fprintf(fout,"%d\n" , br-1);
    //system("pause");
    return 0;
}
