#include<iostream>
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<algorithm>
#include<math.h>
#include"boost/algorithm/string.hpp"

using namespace std;


int main(){
	/*Q3*/
	//w:.
	//b:#
	//#. 禁止

	int n;
	cin >> n;
	string s;
	cin >> s;

	int ret = 0;

	//全数同一

	if (string::npos == s.find('.') || string::npos == s.find('#')){
		cout << 0 << endl;

		return 0;
	}

	std::vector<int> data(300000, 0);
//	int data[300000];
	
	data[0] = 1;

	//区間を求める
	int j = 0;
	int max_data = 0;
	int max_pos = 0;
	int max_char;

	for (int i = 1; i < n; ++i){
		//違う文字
		if (s[i - 1] != s[i]){

			//.の場合は→寄せ、#の場合は左寄せ
			if (
				(s[i - 1] == '#' && max_data < data[j])
				|| s[i - 1] == '.' && max_data <= data[j]
				){
				max_data = data[j];
				max_pos = j;
				max_char = s[i-1];
			}
			j++;
		}
		data[j]++;
	}

	
	//最大の場所からn+1, n+2を比較

	//←
	int start = max_pos;
	int i = start;

	//.の場合は←を全部買える
	if (max_char == '.'){
		for (; -1 < i; i -= 2){
			ret += data[i];
		}
		//→は
		i = start;
		while (data[i + 2] > data[i + 1]){
			ret += data[i + 1];
			i += 2;
		}
		i += 2;
		while (i < n){
			ret += data[i];
			i += 2;
		}

	}

	//#の場合は→を全変える
	else{
		for (; i < n ; i += 2){
			ret += data[i];
		}
		//←は適宜
		i = start;
		while (data[i - 2] > data[i - 1]){
			ret += data[i - 1];
			i -= 2;
		}
		i -= 2;
		while (0 < i){
			ret += data[i];
			i -= 2;
		}

	}


	cout << ret << endl;
	
	return 0;

	/*Q2
	int n;
	cin >> n;
	
	string s;
	cin >> s;
	int k;
	cin >> k;
	k--;

	char c = s[k];

	for (int i = 0; i < s.size(); ++i){
		if (s[i]!= c){
			s[i] = '*';
		}
	}

	cout << s << endl;
	/*Q1*/
	/*
	int a, b, c;
	cin >> a >> b >> c;

	if (a < b){
		if (a < c && c < b){
			cout << "Yes" << endl;
			return 0;
		}
	}

	else{
		if (b < c && c < a){
			cout << "Yes" << endl;
			return 0;
		}


	}

	cout << "No" << endl;
	

	return 0;
	*/
}