#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const long long MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  bool brack = false;
  if (S[0] == '#') brack = true;
  queue<int> bw;
  int count = 1;
  for (int i = 1; i < N; i++) {
    if (S[i - 1] != S[i]) {
      bw.push(count);
      count = 1;
    } else
      count++;
  }
  bw.push(count);
  int ans = 0;
  if (!brack) bw.pop();
  while (bw.size() > 1) {
    int b = bw.front();
    bw.pop();
    int w = bw.front();
    bw.pop();
    ans += min(b, w);
  }
  cout << ans << endl;
}
