#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e5 + 10;
long long main() {
  long long n;
  cin >> n;
  string a;
  cin >> a;
  long long i = n - 1;
  long long ans = 0;
  long long b = 0, w = 0;
  while (i >= 0) {
    if (a[i] == '#') {
      long long j = i;
      while (a[j] == '#' and j >= 0) j--;
      b += i - j;
      i = j;
      if (w > 0) {
        if (w <= b) {
          ans += w;
          b += w;
          w = 0;
        } else {
          ans += b;
          w += b;
          b = 0;
        }
      }
    } else {
      long long j = i;
      while (a[j] == '.' and j >= 0) j--;
      if (j == -1) break;
      w += i - j;
      i = j;
    }
  }
  cout << ans;
}
