#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>

using namespace std;

#include <iostream>
//#include <fstream>

//ifstream cin ("input.in");
//ofstream cout ("output.out");

//ifstream cin (".in")
//ofstream cout (".out");

static const int NMAX = 2*100005;

string s;
int whites[NMAX];
int blacks[NMAX];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	int n;
	cin>>n;
	cin>>s;
 
 	int changes = 0;

 	if ( s[0] == '#' ) {
 		blacks[0] = 1;
 		whites[0] = 0;
 	}

	for ( int i = 1; i < n; ++i ) {
		if ( s[i] == '#' ) {
			blacks[i] = blacks[i-1]+1;
			whites[i] = 0;
		}
	}

	for ( int i = n-1; i >= 0; --i ) {
		if ( s[i] == '.' ) {
			whites[i] = whites[i+1]+1;
			blacks[i] = 0;
		}
	}

	for ( int i = 0; i < n; ++i ) {
		if ( s[i] == '#' && s[i+1] == '.' ) {
			if ( whites[i+1] > blacks[i]  ) {
				int changedToWhite = blacks[i];

				changes += changeToWhite;
				whites[i+1] += changeToWhite;
				
				s[i] = '.';
				blacks[i] = 0;
			} else {
				int changedToBlack = whites[i+1];

				changes += changedToBlack;
				blacks[i+changedToBlack] = blacks[i]+changedToBlack;
				i += changedToBlack+1;

				s[i-1] = '#';
				whites[i-1] = 0;
			}
		}
	}

	cout<<changes<<'\n';
}