#include <bits/stdc++.h>
using namespace std;
const char black = '#';
const char white = '.';
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  string s;
  cin >> n;
  cin >> s;
  vector<int> left(n, -1);
  vector<int> right(n, -1);
  stack<int> st;
  for (int i = 0; i < n; ++i) {
    if (s[i] == white)
      st.push(i);
    else {
      while (!st.empty()) {
        right[st.top()] = i - 1;
        st.pop();
      }
    }
  }
  if (s[n - 1] == white)
    while (!st.empty()) {
      right[st.top()] = n - 1;
      st.pop();
    }
  while (!st.empty()) st.pop();
  for (int i = n - 1; i >= 0; --i) {
    if (s[i] == black) {
      st.push(i);
    } else {
      while (!st.empty()) {
        left[st.top()] = i + 1;
        st.pop();
      }
    }
  }
  if (s[0] == black)
    while (!st.empty()) {
      left[st.top()] = 0;
      st.pop();
    }
  int cnt = 0;
  for (int i = 0; i < n - 1; ++i) {
    if (s[i] == black && s[i + 1] == white) {
      int r = right[i + 1] - (i + 1) + 1;
      int l = i - left[i] + 1;
      if (r <= l) {
        cnt += r;
        s[right[i + 1]] = black;
        right[i + 1] = right[i + 1 + 1];
      } else {
        cnt += l;
        s[left[i]] = white;
        left[i] = left[i - 1];
      }
      i = right[i + 1] - 1;
    }
  }
  cout << cnt << endl;
  return 0;
}
