166
rbbbbbbbbbbbbrbrrbbrbbbrbbbbbbbbbbrbbbbbbrbbbrbbbbbrbbbbbbbrbbbbbbbrbbrbbbbbbbbrbbbbbbbbbbbbbbrrbbbrbbbbbbbbbbbbbbrbrbbbbbbbbbbbrbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbb
 7
rrbrbrb
 1
r
 2
bb
 18
rrrrrrrrrrrrrrrrrb
 8
rbbrbrbr
 1
b
 13
rbbbrbrrbrrbb
 100
brbbbrrrbbrbrbbrbbrbbbbrbbrrbbbrrbbbbrbrbbbbbbbbbbbbbbbbrrrrbbbbrrrbbbbbbbrbrrbrbbbbrrrbbbbrbbrbbbrb
 2
rb
 2
rr
 2
br

70
 1
 0
 1
 8
 1
 0
 3
 34
 0
 1
 0

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n;
char sosk[maxn];
int main() {
  cin >> n;
  int r = 0, b = 0;
  for (int i = 1; i < n; i++) {
    cin >> sosk[i];
    if (sosk[i] == 'r')
      r++;
    else
      b++;
  }
  int q = 0;
  if (abs(r - b) > 1) {
    if (b > r) {
      for (int i = 3; i <= n && abs(r - b) > 1; i++) {
        if (sosk[i - 2] == 'b' && sosk[i - 1] == 'b') {
          if (sosk[i] == 'b') {
            sosk[i - 1] = 'r';
            q++;
          } else {
            sosk[i - 2] = 'r';
            q++;
          }
        }
        if (sosk[i - 2] == 'r' && sosk[i - 1] == 'b') {
          if (sosk[i] == 'b') {
            sosk[i] = 'r';
            q++;
          }
        }
      }
    } else {
      for (int i = 3; i <= n && abs(r - b) > 1; i++) {
        if (sosk[i - 2] == 'r' && sosk[i - 1] == 'r') {
          if (sosk[i] == 'b') {
            sosk[i - 2] = 'b';
            q++;
          } else {
            sosk[i - 1] = 'b';
            q++;
          }
        }
        if (sosk[i - 2] == 'b' && sosk[i - 1] == 'r') {
          if (sosk[i] == 'r') {
            sosk[i] = 'b';
            q++;
          }
        }
      }
    }
  }
  int p = 0;
  for (int i = 2; i <= n; i++) {
    if (sosk[i] == sosk[i - 1]) p++;
  }
  cout << p + q;
}
