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;
bool arr[100002];
string s;
int main() {
  int n, res1 = 0, res2 = 0;
  cin >> n;
  cin >> s;
  for (int i = (int)(1); i < (int)(n + 1); ++i)
    if (s[i - 1] == 'r')
      arr[i] = 1;
    else
      arr[i] = 0;
  arr[0] = !arr[1];
  arr[n + 1] = !arr[n];
  int i = 1;
  while (i <= n) {
    if (arr[i - 1] == arr[i] && arr[i] == arr[i + 1]) {
      arr[i] = !arr[i];
      ++res1;
      ++i;
    } else if (arr[i - 1] == arr[i]) {
      swap(arr[i], arr[i + 1]);
      ++res1;
      i += 2;
    } else
      ++i;
  }
  for (int i = (int)(1); i < (int)(n + 1); ++i)
    if (s[i - 1] == 'r')
      arr[i] = 1;
    else
      arr[i] = 0;
  arr[0] = arr[1];
  arr[n + 1] = !arr[n];
  i = 1;
  while (i <= n) {
    if (arr[i - 1] == arr[i] && arr[i] == arr[i + 1]) {
      arr[i] = !arr[i];
      ++res2;
      ++i;
    } else if (arr[i - 1] == arr[i]) {
      swap(arr[i], arr[i + 1]);
      ++res2;
      i += 2;
    } else
      ++i;
  }
  int res3 = 0, res4 = 0;
  for (int i = (int)(1); i < (int)(n + 1); ++i)
    if (s[i - 1] == 'r')
      arr[i] = 1;
    else
      arr[i] = 0;
  arr[0] = !arr[1];
  arr[n + 1] = !arr[n];
  i = n;
  while (i >= 1) {
    if (arr[i - 1] == arr[i] && arr[i] == arr[i + 1]) {
      arr[i] = !arr[i];
      ++res3;
      --i;
    } else if (arr[i] == arr[i + 1]) {
      swap(arr[i], arr[i - 1]);
      ++res3;
      i -= 2;
    } else
      --i;
  }
  for (int i = (int)(1); i < (int)(n + 1); ++i)
    if (s[i - 1] == 'r')
      arr[i] = 1;
    else
      arr[i] = 0;
  arr[0] = !arr[1];
  arr[n + 1] = arr[n];
  i = n;
  while (i >= 1) {
    if (arr[i - 1] == arr[i] && arr[i] == arr[i + 1]) {
      arr[i] = !arr[i];
      ++res4;
      --i;
    } else if (arr[i] == arr[i + 1]) {
      swap(arr[i], arr[i - 1]);
      ++res4;
      i -= 2;
    } else
      --i;
  }
  cout << min(res1, min(res3, min(res4, res2)));
  return 0;
}
