#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> c(1, 0);
  int ind = 0;
  char prev = '#';
  while (ind < n) {
    if (s[ind] == prev) {
      c[c.size() - 1] += 1;
    } else {
      c.push_back(1);
      prev = s[ind];
    }
    ind += 1;
  }
  if (c.size() % 2 == 1) {
    c.push_back(0);
  }
  int res = 0;
  int i = 0;
  while (i < c.size()) {
    res += min(c[i], c[i + 1]);
    i += 2;
  }
  cout << res << endl;
  return 0;
}
