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;
int sz;
vector<bool> colors;
int DP[(int)1e5 + 5][3][3][3];
int solve(int index, int prev, int p_prev, int p_p_prev) {
  if (p_prev != -1 && p_p_prev == p_prev) {
    return DP[index][prev + 1][p_prev + 1][p_p_prev + 1] = 1e7;
  }
  if (index == sz) {
    return DP[index][prev + 1][p_prev + 1][p_p_prev + 1] = 0;
  }
  if (DP[index][prev + 1][p_prev + 1][p_p_prev + 1] != -1) {
    return DP[index][prev + 1][p_prev + 1][p_p_prev + 1];
  }
  int leave = 1e7, swap = 1e7, change = 1e7, changep = 1e7, chswp = 1e7,
      chpswp = 1e7;
  leave = solve(index + 1, colors[index], prev, p_prev);
  swap = solve(index + 1, prev, colors[index], p_prev) + 1;
  change = solve(index + 1, !colors[index], prev, p_prev) + 1;
  changep =
      solve(index + 1, colors[index], prev == -1 ? prev : !prev, p_p_prev) + 1;
  chswp = solve(index + 1, prev, !colors[index], p_p_prev) + 2;
  chpswp =
      solve(index + 1, prev == -1 ? prev : !prev, colors[index], p_p_prev) + 2;
  return DP[index][prev + 1][p_prev + 1][p_p_prev + 1] = min(
             leave, min(swap, min(change, min(changep, min(chswp, chpswp)))));
}
int main() {
  memset(DP, -1, sizeof(DP));
  cin >> sz;
  colors.resize(sz);
  for (int i = 0; i < sz; i++) {
    char t;
    cin >> t;
    colors[i] = (t == 'b');
  }
  if (sz == 1) {
    cout << "0" << endl;
  } else if (sz == 2) {
    cout << (colors[0] == colors[1]) << endl;
  } else if (sz == 3) {
    cout << ((colors[2] != colors[1] && colors[1] != colors[0]) ? "0" : "1")
         << endl;
  } else {
    int res = 1e7;
    bool prev, p_prev, p_p_prev;
    int pluser;
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 2; k++) {
          p_p_prev = colors[0];
          p_prev = colors[1];
          prev = colors[2];
          pluser = 0;
          if (i % 2) {
            prev = !prev;
            pluser++;
          }
          if (j % 2) {
            p_prev = !p_prev;
            pluser++;
          }
          if (k % 2) {
            p_p_prev = !p_p_prev;
            pluser++;
          }
          res = min(res, solve(3, prev, p_prev, p_p_prev) + pluser);
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}
