#include <bits/stdc++.h>
using namespace std;
long long ans, mx, sum, mn = 1e14, cnt;
long long h[200000], dot[200000];
int main() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == '#') cnt++;
    h[i] = cnt;
  }
  cnt = 0;
  for (long long i = s.size() - 1; i >= 0; i--) {
    if (s[i] == '.')
      cnt++;
    else {
      cnt = 0;
    }
    dot[i] = cnt;
  }
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == '#' && s[i + 1] == '.') {
      mn = min(h[i], dot[i + 1]);
      ans += mn;
    }
  }
  cout << ans;
}
