#include <cstdlib>
#include <iostream>
#include <stdio.h>

using namespace std;

int n, m;
char str[300000];
int rS[300000];
int cS;

int main(int argc, char *argv[])
{
    FILE* f;
    f = fopen("muzej.in", "r");
    fscanf(f, "%d", &n);
    fscanf(f, "%d", &m);
    fscanf(f, "%s", str);
    fclose(f);
    cS = 0;
    int cI = 0;
    if (str[0] == 'b' || str[0] == 'B') rS[cS++] = 0;
    while (cI < n)
    {
        rS[cS] = 1;
        ++cI;
        while (cI < n && str[cI - 1] == str[cI])
        {
            rS[cS]++;
            ++cI;
        }
        cS++;
    }
    int brG = 0;
    int tOst = 0;
    for (int i = 1; i < cS; i += 2)
    {
        rS[i] += tOst;
        if (rS[i] <= rS[i - 1])
        {
            rS[i - 1] -= rS[i];
            rS[i] = 0;
            ++brG;
        }
        else if (rS[i - 1] > 0)
        {
            rS[i] -= rS[i - 1];
            rS[i - 1] = 0;
            ++brG;
        }
        if (rS[i] > 0 && rS[i] <= rS[i + 1])
        {
            rS[i + 1] -= rS[i];
            rS[i] = 0;
            ++brG;
        }
        else if (rS[i] > 0)
        {
            rS[i] -= rS[i + 1];
            rS[i + 1] = 0;
            ++brG;
        }
        tOst = rS[i];
        rS[i] = 0;
    }
    for (int i = 0; i < cS; ++i) brG += rS[i];
    f = fopen("muzej.out", "w");
    fprintf(f, "%d", brG - tOst - 1);
    fclose(f);
    return EXIT_SUCCESS;
}
