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 main() {
  long long n, i, ans = 0, flag = 0, j;
  string input;
  cin >> n;
  cin >> input;
  if (n == 1)
    cout << 0 << "\n";
  else if (n == 2) {
    if (input[0] == input[1])
      cout << 1 << "\n";
    else
      cout << 0 << "\n";
  } else {
    if (n % 2 == 0) {
      if (input[0] == input[n - 2]) {
        for (i = 1; i < (n - 1); i++) {
          flag = 0;
          if (input[i] == input[i - 1]) {
            for (j = (i + 1); j < n; j += 2) {
              if (input[j] != input[i]) {
                flag = 1;
                input[i] = input[j];
                input[j] = input[i - 1];
                ans++;
                break;
              }
            }
            if (flag == 0) {
              ans++;
              if (input[i] == 'b')
                input[i] = 'r';
              else
                input[i] = 'b';
            }
          }
        }
        if (input[n - 1] == input[n - 2]) ans++;
        cout << ans << "\n";
      } else {
        if (input[0] == 'b') {
          if (input[1] == 'r') {
            input[n - 2] = 'b';
            ans++;
          } else {
            input[0] = 'r';
            ans++;
          }
        } else {
          if (input[1] == 'b') {
            input[n - 2] = 'r';
            ans++;
          } else {
            input[0] = 'b';
            ans++;
          }
        }
        for (i = 1; i < (n - 1); i++) {
          flag = 0;
          if (input[i] == input[i - 1]) {
            for (j = (i + 1); j < n; j += 2) {
              if (input[j] != input[i]) {
                flag = 1;
                input[i] = input[j];
                input[j] = input[i - 1];
                ans++;
                break;
              }
            }
            if (flag == 0) {
              ans++;
              if (input[i] == 'b')
                input[i] = 'r';
              else
                input[i] = 'b';
            }
          }
        }
        if (input[n - 1] == input[n - 2]) ans++;
        cout << ans << "\n";
      }
    } else {
      if (input[0] == input[n - 1]) {
        for (i = 1; i < (n - 1); i++) {
          flag = 0;
          if (input[i] == input[i - 1]) {
            for (j = (i + 1); j < n; j += 2) {
              if (input[j] != input[i]) {
                flag = 1;
                input[i] = input[j];
                input[j] = input[i - 1];
                ans++;
                break;
              }
            }
            if (flag == 0) {
              ans++;
              if (input[i] == 'b')
                input[i] = 'r';
              else
                input[i] = 'b';
            }
          }
        }
        if (input[n - 1] == input[n - 2]) ans++;
        cout << ans << "\n";
      } else {
        if (input[0] == 'b') {
          if (input[1] == 'r') {
            input[n - 1] = 'b';
            ans++;
          } else {
            input[0] = 'r';
            ans++;
          }
        } else {
          if (input[1] == 'b') {
            input[n - 1] = 'r';
            ans++;
          } else {
            input[0] = 'b';
            ans++;
          }
        }
        for (i = 1; i < (n - 1); i++) {
          flag = 0;
          if (input[i] == input[i - 1]) {
            for (j = (i + 1); j < n; j += 2) {
              if (input[j] != input[i]) {
                flag = 1;
                input[i] = input[j];
                input[j] = input[i - 1];
                ans++;
                break;
              }
            }
            if (flag == 0) {
              ans++;
              if (input[i] == 'b')
                input[i] = 'r';
              else
                input[i] = 'b';
            }
          }
        }
        if (input[n - 1] == input[n - 2]) ans++;
        cout << ans << "\n";
      }
    }
  }
  return 0;
}
