#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  string S;
  vector<pair<long long, char>> v;
  long long t = 0;
  char c = '.';
  cin >> N;
  cin >> S;
  for (auto i = (S.begin()); i != (S.end()); i++) {
    if (*i != c) {
      v.push_back(make_pair(t, c));
      t = 0;
      c = *i;
    }
    t++;
  }
  v.push_back(make_pair(t, c));
  int i = 0;
  int j = v.size() - 1;
  int sum = 0;
  while (i < v.size() && v.at(i).second != '#') {
    i++;
  }
  while (0 <= j && v.at(j).second != '.') {
    j--;
  }
  while (i <= j) {
    if (v.at(i).first < v.at(j).first) {
      v.at(i).second = '.';
      sum += v.at(i).first;
      while (i < v.size() && v.at(i).second != '#') {
        i++;
      }
    } else {
      v.at(j).second = '#';
      sum += v.at(j).first;
      while (0 <= j && v.at(j).second != '.') {
        j--;
      }
    }
  }
  cout << sum << endl;
  return 0;
}
