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 numberR(char* array, int n) {
  int red = 0;
  for (int i = 0; i < n; i++) {
    if (array[i] == 'r') {
      red++;
    }
  }
  return red;
}
int numberB(char* array, int n) {
  int black = 0;
  for (int i = 0; i < n; i++) {
    if (array[i] == 'b') {
      black++;
    }
  }
  return black;
}
char* swap(char* array, int posA, int posB) {
  char s = array[posA];
  array[posA] = array[posB];
  array[posB] = s;
  return array;
}
char* changeColor(char* array, int pos, char ca) {
  array[pos] = ca;
  return array;
}
int main() {
  int n;
  cin >> n;
  char array[n];
  for (int i = 0; i < n; i++) {
    cin >> array[i];
  }
  int countS = 0;
  int countR = numberR(array, n);
  int countB = numberB(array, n);
  if (n % 2 == 0) {
    for (int i = 0; i < n; i++) {
      if (countR - countB == 0) {
        for (int i = 0; i < n - 1; i++) {
          if (!(array[i] != array[i + 1])) {
            countS++;
            swap(array, i, i + 1);
          }
        }
        cout << countS << '\n';
        return 0;
      } else {
        if (!(array[i] != array[i + 1])) {
          if (array[i] == 'r') {
            changeColor(array, i + 1, 'b');
            countS++;
            countB++;
            countR--;
          } else {
            changeColor(array, i + 1, 'r');
            countS++;
            countR++;
            countB--;
          }
        }
      }
    }
  } else {
    for (int i = 0; i < n; i++) {
      if (countR - countB == 1 || countB - countR == 1) {
        for (int i = 0; i < n - 1; i++) {
          if (!(array[i] != array[i + 1])) {
            countS++;
            swap(array, i, i + 1);
          }
        }
        cout << countS << '\n';
        return 0;
      } else {
        if (!(array[i] != array[i + 1])) {
          if (array[i] == 'r') {
            changeColor(array, i + 1, 'b');
            countS++;
            countB++;
            countR--;
          } else {
            changeColor(array, i + 1, 'r');
            countS++;
            countR++;
            countB--;
          }
        }
      }
    }
  }
}
