#include<bits/stdc++.h>
using namespace std;
int dpr[100100],dpb[100100];
//dpr[i] denotes str[0....i] ending with r and having alternating characters.
//dpb[i] denotes str[0....i] ending with b and having alternating characters.
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
string str;
int n;
cin>>n;
cin>>str;
if(n==1){ //if string length is 1
cout<<0<<"\n";
exit(0);
}
//computing solution for the first two characters str[0] & str[1].
if(str[0]==str[1]){ //if characters are same.
if(str[0]=='r')
dpb[0]=1;
else
dpr[0]=1;
dpr[1]=1;
dpb[1]=1;
}
else{ //if characters are different.
if(str[0]=='r'){
dpb[0]=1;
dpr[1]=1;
}
else{
dpr[0]=1;
dpb[1]=1;
}
}
for(int i=2;i<n;i++){
if(str[i]=='r'){ //this if-else computes solution for coloring str[i] and str[i-1]
dpr[i]=dpb[i-1];
dpb[i]=1+dpr[i-1];
}
else{
dpr[i]=1+dpb[i-1];
dpb[i]=dpr[i-1];
}
if(str[i]!=str[i-1]) //this if-else checks if str[i] and str[i-1] are different, if they are, it checks for swap case.
if(str[i]=='b')
dpr[i]=min(dpr[i],1+dpr[i-2]);
else
dpb[i]=min(dpb[i],1+dpb[i-2]);
}
cout<<min(dpr[n-1],dpb[n-1])<<"\n"; //computes final solution
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IGRwclsxMDAxMDBdLGRwYlsxMDAxMDBdOwovL2RwcltpXSBkZW5vdGVzIHN0clswLi4uLmldIGVuZGluZyB3aXRoIHIgYW5kIGhhdmluZyBhbHRlcm5hdGluZyBjaGFyYWN0ZXJzLgovL2RwYltpXSBkZW5vdGVzIHN0clswLi4uLmldIGVuZGluZyB3aXRoIGIgYW5kIGhhdmluZyBhbHRlcm5hdGluZyBjaGFyYWN0ZXJzLgppbnQgbWFpbigpewogICAgaW9zOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwogICAgY2luLnRpZSgwKTsKICAgIGNvdXQudGllKDApOwogICAgc3RyaW5nIHN0cjsKICAgIGludCBuOwogICAgY2luPj5uOwogICAgY2luPj5zdHI7CiAgICBpZihuPT0xKXsgICAvL2lmIHN0cmluZyBsZW5ndGggaXMgMQogICAgICAgIGNvdXQ8PDA8PCJcbiI7CiAgICAgICAgZXhpdCgwKTsKICAgIH0KCS8vY29tcHV0aW5nIHNvbHV0aW9uIGZvciB0aGUgZmlyc3QgdHdvIGNoYXJhY3RlcnMgc3RyWzBdICYgc3RyWzFdLgogICAgaWYoc3RyWzBdPT1zdHJbMV0peyAgLy9pZiBjaGFyYWN0ZXJzIGFyZSBzYW1lLiAKICAgICAgICBpZihzdHJbMF09PSdyJykgICAKICAgICAgICAgICAgZHBiWzBdPTE7ICAKICAgICAgICBlbHNlCiAgICAgICAgICAgIGRwclswXT0xOwogICAgICAgIGRwclsxXT0xOwogICAgICAgIGRwYlsxXT0xOwogICAgfQogICAgZWxzZXsgICAgICAgICAgICAgICAgLy9pZiBjaGFyYWN0ZXJzIGFyZSBkaWZmZXJlbnQuCiAgICAgICAgaWYoc3RyWzBdPT0ncicpeyAgCiAgICAgICAgICAgIGRwYlswXT0xOwogICAgICAgICAgICBkcHJbMV09MTsKICAgICAgICB9CiAgICAgICAgZWxzZXsKICAgICAgICAgICAgZHByWzBdPTE7CiAgICAgICAgICAgIGRwYlsxXT0xOwogICAgICAgIH0KICAgIH0KICAgIGZvcihpbnQgaT0yO2k8bjtpKyspewogICAgICAgIGlmKHN0cltpXT09J3InKXsgICAgLy90aGlzIGlmLWVsc2UgY29tcHV0ZXMgc29sdXRpb24gZm9yIGNvbG9yaW5nIHN0cltpXSBhbmQgc3RyW2ktMV0KICAgICAgICAgICAgZHByW2ldPWRwYltpLTFdOwogICAgICAgICAgICBkcGJbaV09MStkcHJbaS0xXTsKICAgICAgICB9CiAgICAgICAgZWxzZXsKICAgICAgICAgICAgZHByW2ldPTErZHBiW2ktMV07CiAgICAgICAgICAgIGRwYltpXT1kcHJbaS0xXTsKICAgICAgICB9CiAgICAgICAgaWYoc3RyW2ldIT1zdHJbaS0xXSkgIC8vdGhpcyBpZi1lbHNlIGNoZWNrcyBpZiBzdHJbaV0gYW5kIHN0cltpLTFdIGFyZSBkaWZmZXJlbnQsIGlmIHRoZXkgYXJlLCBpdCBjaGVja3MgZm9yIHN3YXAgY2FzZS4KICAgICAgICAgICAgaWYoc3RyW2ldPT0nYicpCiAgICAgICAgICAgICAgICBkcHJbaV09bWluKGRwcltpXSwxK2RwcltpLTJdKTsKICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgZHBiW2ldPW1pbihkcGJbaV0sMStkcGJbaS0yXSk7CiAgICB9CiAgICBjb3V0PDxtaW4oZHByW24tMV0sZHBiW24tMV0pPDwiXG4iOyAvL2NvbXB1dGVzIGZpbmFsIHNvbHV0aW9uCiAgICByZXR1cm4gMDsKfQ==