#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T>
void chmin(T &a, T b) {
  a = min(a, b);
}
template <typename T>
void chmax(T &a, T b) {
  a = max(a, b);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  vector<int> dot(n, 0), sharp(n, 0);
  int c = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '#')
      c++;
    else {
      dot[i] = c;
      c = 0;
    }
  }
  c = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == '.')
      c++;
    else {
      sharp[i] = c;
      c = 0;
    }
  }
  ll ans = 0;
  for (int i = 1; i < n; i++) {
    ans += min(dot[i], sharp[i - 1]);
  }
  cout << ans << endl;
}
