#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
string s;
ll p[200005],ss[200005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n>>s;
    while(sz(s) and s.back()=='#')
    	s.pop_back();
    reverse(all(s));
    while(sz(s) and s.back()=='.')
    	s.pop_back();
    reverse(all(s));
    vector<pll>v;
    for(ll i=0;i<sz(s);)
    {
    	ll j=i;
    	while(j<sz(s) and s[j]==s[i])
    		j++;
    	if(sz(v) and v.back().S==0)
    		v.back().S=(j-i);
    	else
    		v.pb({j-i,0});
    	i=j;
    }
    rep(i,0,sz(v))
    	p[i]=(i?p[i-1]:0)+v[i].S;
    sep(i,sz(v)-1,0)
    	ss[i]=ss[i+1]+v[i].F;
    ll ans=0;
    if(sz(v))
    	ans=min(p[sz(v)-1],ss[0]);
    rep(i,0,sz(v)-1)
    	ans=min(ans,p[i]+ss[i+1]);
    cout<<ans;
}
