#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename S, typename T>
void xmin(S&a, T const&b){if(b<a) a=b;}
template<typename S, typename T>
void xmax(S&a, T const&b){if(b>a) a=b;}

signed main()
{
    #ifdef LOCAL_RUN
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    int TTT; cin >> TTT; while(TTT--){
    #else
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    #endif // LOCAL_RUN

    int n;
    cin >> n;
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    vector<int> p;
    for(int i=0;i<n;++i){
        if(s[i] == 'P'){
            p.push_back(i);
        }
    }
    if(p.size() == 1){
        int s1, l1, s2, r2;
        s1=s2=0;
        l1=r2=-1;
        for(int i=p[0]-1;i>=0;--i){
            if(s[i]=='*'){
                ++s1;
                l1=i;
            }
        }
        for(int i=p[0]+1;i<n;++i){
            if(s[i]=='*'){
                ++s2;
                r2=i;
            }
        }
        pair<int, int> t1(-s1, p[0]-l1), t2(-s2, r2-p[0]);
        auto t = min(t1, t2);
        cout << -t.first << " " << t.second<<"\n";
    } else {
        // can eat all;
        int cnt = 0;
        for(int i=0;i<n;++i){
            if(s[i] == '*') ++cnt;
        }
        int ans = n;
        for(int it=0;it<2;++it){
            int l=0, r=n;
            string ss;
            while(l+1<r){
                int m = l+(r-l)/2;
                bool f = false;
                int b = -1;
                ss = s;
                // clear best to left
                int cleft = 0;
                int scnt = 0;
                for(int i=n-1;i>=0;--i){
                    --cleft;
                    if(ss[i] == 'P'){
                        if(scnt == 0){
                            cleft=m+1;
                            ss[i] = '.';
                        }
                        scnt = 0;
                    } else if(ss[i] == '*'){
                        if(cleft>0){
                            ss[i] = '.';
                        } else {
                            ++scnt;
                        }
                    }
                }
                //cerr << m << " : " << ss << "\n";
                p.clear();
                for(int i=0;i<n;++i){
                    if(ss[i] == 'P'){
                        p.push_back(i);
                    }
                }

                for(int i=0;i<n;++i){
                    if(ss[i] == '*'){
                        if(b<i){
                            //grab from future
                            auto it = upper_bound(p.begin(), p.end(), i);
                            if(it == p.end()){
                                f=true;
                                break;
                            }
                            auto it2 = next(it);
                            if(it2!=p.end() && *it2-m<=i){
                                it = it2;
                            }
                            if(*it-m>i){
                                f=true;
                                break;
                            }
                            ss[*it] = '.';
                            b = *it;
                        }
                    } else if(ss[i] == 'P'){
                        b = i+m;
                    }
                }
                if(!f){
                    r=m;
                } else {
                    l=m;
                }
            }
            xmin(ans, r);
            //cerr << cnt << " " << r << "\n";
        }
        cout << cnt << " " << ans << "\n";
    }

    #ifdef LOCAL_RUN
    }
    #endif // LOCAL_RUN
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename S, typename T>
void xmin(S&a, T const&b){if(b<a) a=b;}
template<typename S, typename T>
void xmax(S&a, T const&b){if(b>a) a=b;}

signed main()
{
    #ifdef LOCAL_RUN
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    int TTT; cin >> TTT; while(TTT--){
    #else
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    #endif // LOCAL_RUN

    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> p;
    for(int i=0;i<n;++i){
        if(s[i] == 'P'){
            p.push_back(i);
        }
    }
    if(p.size() == 1){
        int s1, l1, s2, r2;
        s1=s2=0;
        l1=r2=-1;
        for(int i=p[0]-1;i>=0;--i){
            if(s[i]=='*'){
                ++s1;
                l1=i;
            }
        }
        for(int i=p[0]+1;i<n;++i){
            if(s[i]=='*'){
                ++s2;
                r2=i;
            }
        }
        pair<int, int> t1(-s1, p[0]-l1), t2(-s2, r2-p[0]);
        auto t = min(t1, t2);
        cout << -t.first << " " << t.second<<"\n";
    } else {
        // can eat all;
        int cnt = 0;
        for(int i=0;i<n;++i){
            if(s[i] == '*') ++cnt;
        }
        int ans = n;
        for(int it=0;it<2;++it){
            int l=0, r=n;
            string ss;
            while(l+1<r){
                int m = l+(r-l)/2;
                bool f = false;
                int b = -1;
                ss = s;
                // clear best to left
                int cleft = 0;
                int scnt = 0;
                for(int i=n-1;i>=0;--i){
                    --cleft;
                    if(ss[i] == 'P'){
                        if(scnt == 0){
                            cleft=m+1;
                            ss[i] = '.';
                        }
                        scnt = 0;
                    } else if(ss[i] == '*'){
                        if(cleft>0){
                            ss[i] = '.';
                        } else {
                            ++scnt;
                        }
                    }
                }
                //cerr << m << " : " << ss << "\n";
                p.clear();
                for(int i=0;i<n;++i){
                    if(ss[i] == 'P'){
                        p.push_back(i);
                    }
                }
                for(int i=0;i<n;++i){
                    if(ss[i] == '*'){
                        if(b<i){
                            //grab from future
                            auto it = upper_bound(p.begin(), p.end(), i);
                            if(it == p.end()){
                                f=true;
                                break;
                            }
                            auto it2 = next(it);
                            if(it2!=p.end() && *it2-m<=i){
                                it = it2;
                            }
                            if(*it-m>i){
                                f=true;
                                break;
                            }
                            ss[*it] = '.';
                            b = *it;
                        }
                    } else if(ss[i] == 'P'){
                        b = i+m;
                    }
                }
                if(!f){
                    r=m;
                } else {
                    l=m;
                }
            }
            xmin(ans, r);
            //cerr << cnt << " " << r << "\n";
            reverse(s.begin(), s.end());
        }
        cout << cnt << " " << ans << "\n";
    }

    #ifdef LOCAL_RUN
    }
    #endif // LOCAL_RUN
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename S, typename T>
void xmin(S&a, T const&b){if(b<a) a=b;}
template<typename S, typename T>
void xmax(S&a, T const&b){if(b>a) a=b;}

signed main()
{
    #ifdef LOCAL_RUN
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    int TTT; cin >> TTT; while(TTT--){
    #else
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    #endif // LOCAL_RUN

    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> p;
    for(int i=0;i<n;++i){
        if(s[i] == 'P'){
            p.push_back(i);
        }
    }
    if(p.size() == 1){
        int s1, l1, s2, r2;
        s1=s2=0;
        l1=r2=-1;
        for(int i=p[0]-1;i>=0;--i){
            if(s[i]=='*'){
                ++s1;
                l1=i;
            }
        }
        for(int i=p[0]+1;i<n;++i){
            if(s[i]=='*'){
                ++s2;
                r2=i;
            }
        }
        pair<int, int> t1(-s1, p[0]-l1), t2(-s2, r2-p[0]);
        auto t = min(t1, t2);
        cout << -t.first << " " << t.second<<"\n";
    } else {
        // can eat all;
        int cnt = 0;
        for(int i=0;i<n;++i){
            if(s[i] == '*') ++cnt;
        }
        int l=0, r=n;
        string ss;
        while(l+1<r){
            int m = l+(r-l)/2;
            bool f = false;
            int b = -1;
            ss = s;
            // clear best to left
            int cleft = 0;
            int scnt = 0;
            for(int i=n-1;i>=0;--i){
                --cleft;
                if(ss[i] == 'P'){
                    if(scnt == 0){
                        cleft=m+1;
                        ss[i] = '.';
                    }
                    scnt = 0;
                } else if(ss[i] == '*'){
                    if(cleft>0){
                        ss[i] = '.';
                    } else {
                        ++scnt;
                    }
                }
            }
            //cerr << m << " : " << ss << "\n";
            p.clear();
            for(int i=0;i<n;++i){
                if(ss[i] == 'P'){
                    p.push_back(i);
                }
            }

            for(int i=0;i<n;++i){
                if(ss[i] == '*'){
                    if(b<i){
                        //grab from future
                        auto it = upper_bound(p.begin(), p.end(), i);
                        if(it == p.end()){
                            f=true;
                            break;
                        }
                        auto it2 = next(it);
                        if(it2!=p.end() && *it2-m<=i){
                            it = it2;
                        }
                        if(*it-m>i){
                            f=true;
                            break;
                        }
                        ss[*it] = '.';
                        b = *it;
                    }
                } else if(ss[i] == 'P'){
                    b = i+m;
                }
            }
            if(!f){
                r=m;
            } else {
                l=m;
            }
        }
        cout << cnt << " " << r << "\n";
    }

    #ifdef LOCAL_RUN
    }
    #endif // LOCAL_RUN
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename S, typename T>
void xmin(S&a, T const&b){if(b<a) a=b;}
template<typename S, typename T>
void xmax(S&a, T const&b){if(b>a) a=b;}

signed main()
{
    #ifdef LOCAL_RUN
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    int TTT; cin >> TTT; while(TTT--){
    #else
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    #endif // LOCAL_RUN

    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> p;
    for(int i=0;i<n;++i){
        if(s[i] == 'P'){
            p.push_back(i);
        }
    }
    if(p.size() == 1){
        int s1, l1, s2, r2;
        s1=s2=0;
        l1=r2=-1;
        for(int i=p[0]-1;i>=0;--i){
            if(s[i]=='*'){
                ++s1;
                l1=i;
            }
        }
        for(int i=p[0]+1;i<n;++i){
            if(s[i]=='*'){
                ++s2;
                r2=i;
            }
        }
        pair<int, int> t1(-s1, p[0]-l1), t2(-s2, r2-p[0]);
        auto t = min(t1, t2);
        cout << -t.first << " " << t.second<<"\n";
    } else {
        // can eat all;
        int cnt = 0;
        for(int i=0;i<n;++i){
            if(s[i] == '*') ++cnt;
        }
        int ans = n;
        for(int it=0;it<2;++it){
            int l=0, r=n;
            string ss;
            while(l+1<r){
                int m = l+(r-l)/2;
                bool f = false;
                int b = -1;
                ss = s;
                // clear best to left
                int cleft = 0;
                int scnt = 0;
                for(int i=n-1;i>=0;--i){
                    --cleft;
                    if(ss[i] == 'P'){
                        if(scnt == 0){
                            cleft=m+1;
                            ss[i] = '.';
                        }
                        scnt = 0;
                    } else if(ss[i] == '*'){
                        if(cleft>0){
                            ss[i] = '.';
                        } else {
                            ++scnt;
                        }
                    }
                }
                //cerr << m << " : " << ss << "\n";
                p.clear();
                for(int i=0;i<n;++i){
                    if(ss[i] == 'P'){
                        p.push_back(i);
                    }
                }

                for(int i=0;i<n;++i){
                    if(ss[i] == '*'){
                        if(b<i){
                            //grab from future
                            auto it = upper_bound(p.begin(), p.end(), i);
                            if(it == p.end()){
                                f=true;
                                break;
                            }
                            auto it2 = next(it);
                            if(it2!=p.end() && *it2-m<=i){
                                it = it2;
                            }
                            if(*it-m>i){
                                f=true;
                                break;
                            }
                            ss[*it] = '.';
                            b = *it;
                        }
                    } else if(ss[i] == 'P'){
                        b = i+m;
                    }
                }
                if(!f){
                    r=m;
                } else {
                    l=m;
                }
            }
            xmin(ans, r);
            //cerr << cnt << " " << r << "\n";
        }
        cout << cnt << " " << ans << "\n";
    }

    #ifdef LOCAL_RUN
    }
    #endif // LOCAL_RUN
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <queue>
#include <vector>

using namespace std;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	return x*f;
}

int n,sum[1000050],p[1000050],ptot,f[1000050];

char s[1000050];

inline bool check(int l,int r)
{
	return (l>r) || (sum[r]-sum[l-1]<=0);
}

inline bool check(int x)
{
	memset(f,0,sizeof(f));
	for (int i=1;i<=ptot;i++)
	{
		if (check(f[i-1]+1,p[i]-x-1))
			f[i]=max(f[i],p[i]);
		if (check(f[i-1]+1,p[i]-1))
			f[i]=max(f[i],p[i]+x);
		if (i>1 && check(f[i-2]+1,p[i]-x-1))
			f[i]=max(f[i],p[i-1]+x);
	}
	return check(f[ptot]+1,n);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin >> n >> (s+1);
	for (int i=1;i<=n;i++)
	{
		sum[i]=sum[i-1]+(s[i]=='*');
		if (s[i]=='P')
			p[++ptot]=i;
	}
	if (ptot==1)
	{
		int p1=sum[p[ptot]],p2=sum[n]-sum[p[ptot]];
		int c1=p[1]-1,c2=n-p[1],i=1;
		while (p[i]=='.')
		{
			c1--;
			i++;
		}
		i=n;
		while (p[i]=='.')
		{
			c2--;
			i--;
		}
		if (p1>p2 || (p1==p2 && c1<c2))
			cout << p1 << " " << c1 << endl;
		else
			cout << p2 << " " << c2 << endl;
		return 0;
	}
	cout << sum[n] << " ";
	int left=1,right=n,ans=0;
	while (left<=right)
	{
		int mid=(left+right)>>1;
		if (check(mid))
		{
			ans=mid;
			right=mid-1;
		}
		else
			left=mid+1;
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <queue>
#include <vector>

using namespace std;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	return x*f;
}

int n,sum[1000050],p[1000050],ptot,f[1000050];

char s[1000050];

inline bool check(int l,int r)
{
	return (l>r) || (sum[r]-sum[l-1]<=0);
}

inline bool check(int x)
{
	memset(f,0,sizeof(f));
	for (int i=1;i<=ptot;i++)
	{
		if (check(f[i-1]+1,p[i]-x-1))
			f[i]=max(f[i],p[i]);
		if (check(f[i-1]+1,p[i]-1))
			f[i]=max(f[i],p[i]+x);
		if (i>1 && check(f[i-2]+1,p[i]-x-1))
			f[i]=max(f[i],p[i-1]+x);
	}
	return check(f[ptot]+1,n);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin >> n >> (s+1);
	for (int i=1;i<=n;i++)
	{
		sum[i]=sum[i-1]+(s[i]=='*');
		if (s[i]=='P')
			p[++ptot]=i;
	}
	if (ptot==1)
	{
		int p1=sum[p[ptot]],p2=sum[n]-sum[p[ptot]];
		int c1=p[1]-1,c2=n-p[1],i=1;
		while (s[i]=='.')
		{
			c1--;
			i++;
		}
		i=n;
		while (s[i]=='.')
		{
			c2--;
			i--;
		}
		if (p1>p2 || (p1==p2 && c1<c2))
			cout << p1 << " " << c1 << endl;
		else
			cout << p2 << " " << c2 << endl;
		return 0;
	}
	cout << sum[n] << " ";
	int left=1,right=n,ans=0;
	while (left<=right)
	{
		int mid=(left+right)>>1;
		if (check(mid))
		{
			ans=mid;
			right=mid-1;
		}
		else
			left=mid+1;
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 1e6+3;
int n, p[N], pac, pref[N], tmp[N];

int cnt(int l, int r){
	if (r < l) return 0;
	return pref[r] - pref[l-1];
}

bool sat(int d){
	bool flag = 1;
	for (int i = 1; i < pac; i++){
		if (cnt(tmp[i-1] + 1, p[i] - d - 1)) {flag = 0; break;}
		else if (cnt(tmp[i-1] + 1, p[i] - 1) == 0) tmp[i] = p[i] + d;
		else tmp[i] = max(p[i], tmp[i-1]);
		//  if (i > 1 && cnt(tmp[i-2]+1,p[i]-d-1)==0) tmp[i] = max(p[i-1] +d, p[i]);
		// else tmp[i] = p[i];
	}
	return (flag && cnt(tmp[pac-1] + 1, n) == 0);
}

int main(){
	cin >> n;
	pac = 1;
	int lt = -1, rt;
	string s; cin >> s;
	for (int i = 0; i < n; i++){
		if (s[i] == '*') pref[i+1] = pref[i] + 1;
		else pref[i+1] = pref[i];
		if (s[i] == 'P') p[pac++] = i + 1;
		if (lt == -1 && s[i] == '*') lt = i + 1;
		if (s[i] == '*') rt = i + 1;
	}
	if (pac == 2){
		int x = pref[p[1]], y = pref[n] - pref[p[1]-1];
		if (x > y) cout << x << " " << p[1] - lt << endl;
		else if (x < y) cout << y << " " << rt - p[1] << endl;
		else cout << x << " " << min(p[1] - lt, rt - p[1]) << endl;
		return 0;
	} else {
		int l = 1, r = n;
		while (l < r){
			int m = (l + r) >> 1;
			if (sat(m)) r = m;
			else l = m + 1;
		}
		cout << pref[n] << " " << l << endl;
	}
}


#include <bits/stdc++.h>
using namespace std;

const int N = 1e6+3;
int n, p[N], pac, pref[N], tmp[N];

int cnt(int l, int r){
	if (r < l) return 0;
	return pref[r] - pref[l-1];
}

bool sat(int d){
	bool flag = 1;
	for (int i = 1; i < pac; i++){
		if (cnt(tmp[i-1] + 1, p[i] - d - 1)) {flag = 0; break;}
		else if (cnt(tmp[i-1] + 1, p[i] - 1) == 0) tmp[i] = p[i] + d;
		else if (i > 1 && cnt(tmp[i-2]+1,p[i]-d-1)==0) tmp[i] = max(tmp[i-1] +d, p[i]);
		else tmp[i] = p[i];
	}
	return (flag && cnt(tmp[pac-1] + 1, n) == 0);
}

int main(){
	cin >> n;
	pac = 1;
	string s; cin >> s;
	for (int i = 0; i < n; i++){
		if (s[i] == '*') pref[i+1] = pref[i] + 1;
		else pref[i+1] = pref[i];
		if (s[i] == 'P') p[pac++] = i + 1;
	}
	if (pac == 2){
		int x = pref[p[1]], y = pref[n] - pref[p[1]-1];
		if (x > y) cout << x << " " << p[1] - 1 << endl;
		else if (x < y) cout << y << " " << n - p[1] << endl;
		else cout << x << " " << min(p[1] - 1, n - p[1]) << endl;
		return 0;
	} else {
		int l = 1, r = n;
		while (l < r){
			int m = (l + r) >> 1;
			if (sat(m)) r = m;
			else l = m + 1;
		}
		cout << pref[n] << " " << l << endl;
	}
}


#include <bits/stdc++.h>
using namespace std;

const int N = 1e6+3;
int n, p[N], pac, pref[N], tmp[N];

int cnt(int l, int r){
	if (r < l) return 0;
	return pref[r] - pref[l-1];
}

bool sat(int d){
	bool flag = 1;
	for (int i = 1; i < pac; i++){
		if (cnt(tmp[i-1] + 1, p[i] - d - 1)) {flag = 0; break;}
		else if (cnt(tmp[i-1] + 1, p[i] - 1) == 0) tmp[i] = p[i] + d;
		else if (i > 1 && cnt(tmp[i-2]+1,p[i]-d-1)==0) tmp[i] = max(tmp[i-1] +d, p[i]);
		else tmp[i] = p[i];
	}
	return (flag && cnt(tmp[pac-1] + 1, n) == 0);
}

int main(){
	cin >> n;
	pac = 1;
	int lt = -1, rt;
	string s; cin >> s;
	for (int i = 0; i < n; i++){
		if (s[i] == '*') pref[i+1] = pref[i] + 1;
		else pref[i+1] = pref[i];
		if (s[i] == 'P') p[pac++] = i + 1;
		if (lt == -1 && s[i] == '*') lt = i + 1;
		if (s[i] == '*') rt = i + 1;
	}
	if (pac == 2){
		int x = pref[p[1]], y = pref[n] - pref[p[1]-1];
		if (x > y) cout << x << " " << p[1] - lt << endl;
		else if (x < y) cout << y << " " << rt - p[1] << endl;
		else cout << x << " " << min(p[1] - lt, rt - p[1]) << endl;
		return 0;
	} else {
		int l = 1, r = n;
		while (l < r){
			int m = (l + r) >> 1;
			if (sat(m)) r = m;
			else l = m + 1;
		}
		cout << pref[n] << " " << l << endl;
	}
}


#include <bits/stdc++.h>
using namespace std;

const int N = 1e6+3;
int n, p[N], pac, pref[N], tmp[N];

int cnt(int l, int r){
	if (r < l) return 0;
	return pref[r] - pref[l-1];
}

bool sat(int d){
	bool flag = 1;
	for (int i = 1; i < pac; i++){
		if (cnt(tmp[i-1] + 1, p[i] - d - 1)) {flag = 0; break;}
		else if (cnt(tmp[i-1] + 1, p[i] - 1) == 0) tmp[i] = p[i] + d;
		else if (i > 1 && cnt(tmp[i-2]+1,p[i]-d-1)==0) tmp[i] = max(p[i-1] +d, p[i]);
		else tmp[i] = p[i];
	}
	return (flag && cnt(tmp[pac-1] + 1, n) == 0);
}

int main(){
	cin >> n;
	pac = 1;
	int lt = -1, rt;
	string s; cin >> s;
	for (int i = 0; i < n; i++){
		if (s[i] == '*') pref[i+1] = pref[i] + 1;
		else pref[i+1] = pref[i];
		if (s[i] == 'P') p[pac++] = i + 1;
		if (lt == -1 && s[i] == '*') lt = i + 1;
		if (s[i] == '*') rt = i + 1;
	}
	if (pac == 2){
		int x = pref[p[1]], y = pref[n] - pref[p[1]-1];
		if (x > y) cout << x << " " << p[1] - lt << endl;
		else if (x < y) cout << y << " " << rt - p[1] << endl;
		else cout << x << " " << min(p[1] - lt, rt - p[1]) << endl;
		return 0;
	} else {
		int l = 1, r = n;
		while (l < r){
			int m = (l + r) >> 1;
			if (sat(m)) r = m;
			else l = m + 1;
		}
		cout << pref[n] << " " << l << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 1000100;

int n;
char a[maxn + 5];

inline bool check(int x)
{
	vector<int> man, aster;
	REP(i, 0, n)
	{
		if (a[i] == 'P') man.pb(i);
		else if (a[i] == '*') aster.pb(i);
	}
	int nman = SZ(man), naster = SZ(aster);
	static bool dp[maxn + 5][2];
	memset(dp, 0, sizeof dp);
	int j = nman - 1;
	dp[naster][0] = dp[naster][1] = 1;
	for (int i = naster - 1; i >= 0; --i)
	{
		j = min(SZ(man) - 1, j + 1);
		while (j >= 0 && man[j] > aster[i])
		{
			bool ok = 0;
			if (man[j] - x <= aster[i])
			{
				int tmp = man[j];
				if (j && man[j - 1] > aster[i]) chkmax(tmp, man[j - 1] + x);
				int fir = upper_bound(ALL(aster), tmp) - aster.begin();
				if (fir == naster || (j + 1 < SZ(man) && aster[fir] > man[j + 1])) ok = dp[fir][1];
				else ok = dp[fir][0];
			}
			if (ok)
			{
				dp[i][0] = 1;
				break;
			}
			--j;
		}
		if (dp[i][0]) dp[i][1] = 1;
		else
		{
			if (j >= 0)
			{
				int tmp = man[j] + x;
				int fir = upper_bound(ALL(aster), tmp) - aster.begin();
				if (fir == naster || (j + 1 < SZ(man) && aster[fir] > man[j + 1]))
				{
					dp[i][1] = dp[fir][1];
				}
				else dp[i][1] = dp[fir][0];
			}
		}
	}
	return dp[0][1];
}

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	scanf("%s", a);
	bool unique = 1;
	int p = -1;
	int Max = 0, Min = oo;
	int tot = 0, left = 0;
	REP(i, 0, n)
		if (a[i] == 'P')
		{
			if (~p)
			{
				unique = 0;
			}
			else
			{
				left = tot;
				p = i;
			}
		}
		else if (a[i] == '*')
		{
			++tot;
			chkmin(Min, i), chkmax(Max, i);
		}
	if (unique)
	{
		int right = tot - left;
		int left_dis = p - Min;
		int right_dis = Max - p;
		auto tmp = max(mp(left, -left_dis), mp(right, -right_dis));
		tmp.y = -tmp.y;
		printf("%d %d\n", tmp.x, tmp.y);
	}
	else
	{
		int l = 0, r = n;
		while (l < r)
		{
			int mid = (l + r) >> 1;
			if (check(mid)) r = mid;
			else l = mid + 1;
		}
		printf("%d %d\n", tot, l);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,sumb,sumd,ans;
int wt[1000010],suf[1000010],flg[1000010];
int read(){
	int r=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c<='9'&&c>='0') r=(r<<1)+(r<<3)+c-'0',c=getchar();
	return r*f;
}
void put(int x){
	 if(x<0){putchar('-');x=~x+1;}
	 if(x>9) put(x/10);
	 putchar(x%10+'0');
}
int check(int x){
	memset(flg,0,sizeof(flg));flg[0]=1;
	for(int i=1;i<=n;i++){
		if(!flg[i-1]) continue;
		if(wt[i]^1) flg[i]=1;
		else{
			if(i<suf[i]-x) continue;
			flg[min(suf[i],n)]=1;
			if(i<suf[suf[i]]-x) continue;
			flg[min(min(suf[i]+x,suf[suf[suf[i]]]-1),n)]=1;
		}
		if(!(wt[i]^-1)) flg[min(min(i+x,suf[i]-1),n)]=1;
	}
	return flg[n];
}
int main(){
//	freopen("dogs.in","r",stdin);
//	freopen("dogs.out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++){
		char c=getchar();
		if(c=='.') wt[i]=0;
		else if(c=='*') wt[i]=1,sumb++;
		else wt[i]=-1,sumd++;
	}
	if(sumd<=1){
		int dpl=0,cnta=0,cntb=0,fbpl=0,lbpl=0;
		for(int i=1;i<=n;i++)
			if(wt[i]==-1){dpl=i;break;}
		for(int i=1;i<dpl;i++)
			if(wt[i]==1){
				if(!fbpl) fbpl=i;
				cnta++;
			}
		for(int i=n;i>dpl;i--)
			if(wt[i]==1){
				if(!lbpl) lbpl=i;
				cntb++;
			}
		if(cnta>cntb){put(cnta);printf(" ");put(dpl-fbpl);puts("");}
		else if(cnta<cntb){put(cntb);printf(" ");put(lbpl-dpl);puts("");}
		else{put(cnta);printf(" ");put(min(dpl-fbpl,lbpl-dpl));puts("");}
		return 0;
	}
	put(sumb);printf(" ");
	for(int i=n;i>=1;i--)
		if(wt[i+1]==-1) suf[i]=i+1;
		else suf[i]=suf[i+1];
	for(int i=1;i<=n;i++)
		if(!suf[i]) suf[i]=1e9;
	int l=1,r=n;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	put(ans);puts("");
	return 0;
}


#include <cstdio>
#include <cctype>
#define re register
#define min(x,y) ((x)<(y)?(x):(y))
#define max(x,y) ((x)>(y)?(x):(y))
using namespace std;
inline int read(){
	int f=1,r=0;char c=getchar();
	while(!isdigit(c))f^=c=='-',c=getchar();
	while(isdigit(c))r=(r<<1)+(r<<3)+(c^48),c=getchar();
	return f?r:-r;
}
const int MAXN=1e6+3;
int n,cd,cb,suf[MAXN];
char s[MAXN];bool f[MAXN];
namespace tp{
inline void solve(){
	int z=0,y=0,zz,yy,d;
	for(re int i=1;i<=n;i++)if(s[i]=='*'){zz=i;break;}
	for(re int i=n;i;i--)if(s[i]=='*'){yy=i;break;}
	for(re int i=1;i<=n;i++)if(s[i]=='P'){d=i;break;}
	for(re int i=1;i<d;i++)z+=s[i]=='*';
	for(re int i=n;i>d;i--)y+=s[i]=='*';
	if(z>y)printf("%d %d",z,d-zz);
	else if(y>z)printf("%d %d",y,yy-d);
	else printf("%d %d",z,min(d-zz,yy-d));
}}
inline bool check(int d){
	for(re int i=1;i<=n;i++)f[i]=0;
	for(re int i=1;i<=n;i++)
		if(f[i-1]){
			if(s[i]=='.')f[i]=1;
			else if(s[i]=='P')f[min(min(i+d,n),suf[i]-1)]=1;
			else if(suf[i]-i<=d){
				f[suf[i]]=1;
				if(suf[suf[i]]-i<=d)
					f[min(suf[suf[suf[i]]]-1,min(suf[i]+d,n))]=1;
			}
		}
	return f[n];
}
int main(){
	n=read();scanf("%s",s+1);suf[n+1]=1e9;
	for(re int i=n;i;i--)cb+=s[i]=='*',cd+=s[i]=='P',suf[i]=s[i+1]=='P'?i+1:suf[i+1];
	if(cd==1) return tp::solve(),0;
	printf("%d ",cb);int l=1,r=n,ans=1;f[0]=1;
	while(l<=r){
		int mid=l+r>>1;
		if(check(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d\n",ans);
	return 0;
}


#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
#define NDEBUG
#endif
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int N=1000005;
int n;
char s[N];
void sol0(){
	puts("0 0");
	exit(0);
}
void sol1(){
	int pos=-1;
	rep(i,1,n)if(s[i]=='D'){pos=i;break;}
	int cnt=0,fir=0;
	rep(i,1,pos-1){
		if(s[i]=='B'){
			++cnt;
			if(!fir)fir=i;
		}
	}
	int tot=0,lst=0;
	per(i,n,pos+1){
		if(s[i]=='B'){
			++tot;
			if(!lst)lst=i;
		}
	}
	if(cnt>tot){
		printf("%d %d\n",cnt,pos-fir);
	}else{
		if(tot==0){
			puts("0 0");
		}else if(cnt==tot){
			printf("%d %d\n",cnt,min(pos-fir,lst-pos));
		}else{
			printf("%d %d\n",tot,lst-pos);
		}
	}
	exit(0);
}
const int INF=0X3F3F3F3F;
int st[N],pos[N],nxt[N],pre[N],f[N],go[N];
void sol2(){
	printf("%d ",(int)count(s+1,s+1+n,'B'));
	int l=0,r=n,ans=INF;
	int top=0,len=0;
	rep(i,1,n){
		if(s[i]=='D')st[++top]=i,pre[i]=pos[len];
		else if(s[i]=='B')pos[++len]=i;
	}
	int tmp=n+1;
	per(i,n,1){
		if(s[i]=='D')nxt[i]=tmp;
		else if(s[i]=='B')tmp=i;
	}
	auto chk=[&](int mid)->bool{
		rep(i,0,top)f[i]=-INF;
		go[0]=1;
		rep(i,1,top){
			f[i]=max(f[i-1],f[i]);
			if(pre[st[i]]==0||pre[st[i]]<st[i-1]||f[i-1]+mid>=pre[st[i]]){
				f[i]=st[i];
			}else{
				int j=go[i-1];
				if(j<=len&&st[i]-pos[j]>mid)return 0;
				if(i>=2){
					j=go[i-2];
					if(j>len||st[i]-pos[j]<=mid){
						f[i]=st[i-1];
					}
				}
			}
			go[i]=go[i-1];
			while(go[i]<=len&&pos[go[i]]<=max(st[i],f[i]+mid))++go[i];
		}
		return max(st[top],f[top]+mid)>=pos[len];
	};
	while(l<=r){
		int mid=(l+r)>>1;
		//D("chk(%d)=%d\n",mid,chk(mid));
		if(chk(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d\n",ans);
	exit(0);
}
int main(){
	scanf("%d%s",&n,s+1);
	rep(i,1,n){
		if(s[i]=='*')s[i]='B';
		else if(s[i]=='P')s[i]='D';
	}
	int cntD=count(s+1,s+1+n,'D');
	if(cntD==0)sol0();
	else if(cntD==1)sol1();
	else sol2();
	return 0;
}


#include <cstdio>
#include <algorithm>

#define MAXN 1000010

int n;
char s[MAXN << 1];

bool chk(const int &d) {
  for (int i = 1, j = -1; i <= n; ++i) {
    if (s[i] == 'D') {
      j = i + d;
    }
    if (s[i] == 'B') {
      if (j >= i) continue;
      int k = i + 1, fi = 0, se = 0, lst = 0;
      while (true) {
        if (s[k] == 'D') {
          if (!fi) {
            fi = k;
          } else {
            se = k;
            if (se > i + d) {
              j = se;
            } else if (lst) {
              j = fi + d;
            } else {
              j = se + d;
            }
            i = se;
            break;
          }
        }
        if (s[k] == 'B' && fi && !lst) lst = k;
        ++k;
        if (!fi && k > i + d) return false;
        if (lst && k > lst + d) return false;
      }
    }
  }
  return true;
}

int main() {
  scanf("%d%s", &n, s + 1);
  for (int i = 1; i <= n; ++i) {
    if (s[i] == '*') s[i] = 'B';
    if (s[i] == 'P') s[i] = 'D';
  }
  int tot = 0, pan = 0;
  for (int i = 1; i <= n; ++i) {
    if (s[i] == 'B') ++tot;
    if (s[i] == 'D') {
      if (!pan) {
        pan = i;
      } else {
        pan = -1;
      }
    }
  }
  if (~pan) {
    int ans1 = 0, ans2 = 0, res = 0, lst = pan;
    for (int i = pan; i >= 1; --i) {
      if (s[i] == 'B') {
        ++res;
        lst = i;
      }
    }
    ans1 = res;
    ans2 = pan - lst;
    res = 0;
    lst = pan;
    for (int i = pan; i <= n; ++i) {
      if (s[i] == 'B') {
        ++res;
        lst = i;
      }
    }
    if (res > ans1) {
      ans1 = res;
      ans2 = lst - pan;
    } else if (res == ans1) {
      ans2 = std::min(ans2, lst - pan);
    }
    printf("%d %d\n", ans1, ans2);
    return 0;
  }
  int l = 0, r = n;
  while (l + 1 < r) {
    const int mid = (l + r) >> 1;
    if (chk(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  printf("%d %d\n", tot, r);
  return 0;
}

/*
6
B.DBDB

8
B...D..B

*/


#include <cstdio>
#include <cstring>
#include <algorithm>

#define MAXN 1000010

int n, tot;
char s[MAXN];
int sum[MAXN], dp[MAXN], dogs[MAXN];

inline void chkmax(int &x, const int &y) {
  x < y && (x = y);
}
inline bool none(const int &l, const int &r) {
  return l > r || sum[l - 1] == sum[r];
}

bool chk(const int &d) {
  memset(dp, 0, sizeof dp);
  for (int i = 1; i <= tot; ++i) {
    if (none(dp[i] + 1, dogs[i] - d - 1)) chkmax(dp[i + 1], dogs[i]);
    if (none(dp[i] + 1, dogs[i] - 1)) chkmax(dp[i + 1], dogs[i] + d);
    if (i != 1 && none(dp[i - 1] + 1, dogs[i] - d - 1)) chkmax(dp[i + 1], dogs[i - 1] + d);
  }
  return none(dp[tot + 1] + 1, n);
}

int main() {
  scanf("%d%s", &n, s + 1);
  for (int i = 1; i <= n; ++i) {
    if (s[i] == '*') s[i] = 'B';
    if (s[i] == 'P') s[i] = 'D';
    sum[i] = sum[i - 1] + (s[i] == 'B');
    if (s[i] == 'D') dogs[++tot] = i;
  }
  if (tot == 1) {
    const int pan = dogs[1];
    int ans1 = 0, ans2 = 0, res = 0, lst = pan;
    for (int i = pan; i >= 1; --i) {
      if (s[i] == 'B') {
        ++res;
        lst = i;
      }
    }
    ans1 = res;
    ans2 = pan - lst;
    res = 0;
    lst = pan;
    for (int i = pan; i <= n; ++i) {
      if (s[i] == 'B') {
        ++res;
        lst = i;
      }
    }
    if (res > ans1) {
      ans1 = res;
      ans2 = lst - pan;
    } else if (res == ans1) {
      ans2 = std::min(ans2, lst - pan);
    }
    printf("%d %d\n", ans1, ans2);
    return 0;
  }
  int l = 0, r = n;
  while (l + 1 < r) {
    const int mid = (l + r) >> 1;
    if (chk(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  printf("%d %d\n", sum[n], r);
  return 0;
}

/*
6
B.DBDB

8
B...D..B

19
**P.*..*..P..*.*P**

*/


#include <cstdio>
#include <algorithm>

#define MAXN 1000010

int n;
char s[MAXN << 1];

bool chk(const int &d) {
  for (int i = 1, j = -1; i <= n; ++i) {
    if (s[i] == 'D') {
      j = i + d;
    }
    if (s[i] == 'B') {
      if (j >= i) continue;
      int k = i + 1, fi = 0, se = 0, lst = 0;
      while (true) {
        if (s[k] == 'D') {
          if (!fi) {
            fi = k;
          } else {
            se = k;
            if (se > i + d) {
              j = se;
            } else if (lst) {
              j = fi + d;
            } else {
              j = se + d;
            }
            i = se;
            break;
          }
        }
        if (s[k] == 'B' && fi && !lst) lst = k;
        ++k;
        if (!fi && k > i + d) return false;
        if (lst && k > lst + d) return false;
        if (k > n) {
          if (!fi) return false;
          if (fi && !lst) return true;
          return false;
        }
      }
    }
  }
  return true;
}

int main() {
  scanf("%d%s", &n, s + 1);
  for (int i = 1; i <= n; ++i) {
    if (s[i] == '*') s[i] = 'B';
    if (s[i] == 'P') s[i] = 'D';
  }
  int tot = 0, pan = 0;
  for (int i = 1; i <= n; ++i) {
    if (s[i] == 'B') ++tot;
    if (s[i] == 'D') {
      if (!pan) {
        pan = i;
      } else {
        pan = -1;
      }
    }
  }
  if (~pan) {
    int ans1 = 0, ans2 = 0, res = 0, lst = pan;
    for (int i = pan; i >= 1; --i) {
      if (s[i] == 'B') {
        ++res;
        lst = i;
      }
    }
    ans1 = res;
    ans2 = pan - lst;
    res = 0;
    lst = pan;
    for (int i = pan; i <= n; ++i) {
      if (s[i] == 'B') {
        ++res;
        lst = i;
      }
    }
    if (res > ans1) {
      ans1 = res;
      ans2 = lst - pan;
    } else if (res == ans1) {
      ans2 = std::min(ans2, lst - pan);
    }
    printf("%d %d\n", ans1, ans2);
    return 0;
  }
  int l = 0, r = n;
  while (l + 1 < r) {
    const int mid = (l + r) >> 1;
    if (chk(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  printf("%d %d\n", tot, r);
  return 0;
}

/*
6
B.DBDB

8
B...D..B

*/


#include<bits/stdc++.h>
using namespace std;
int n,x[1100001],sum[1100001],dp[1100001],cnt=0;
char s[1100001];
bool none(int l,int r) {return l>r||sum[l-1]==sum[r];}
void update(int &a,int b) {if(a<b)a=b;}
bool check(int t) {
	memset(dp,0,sizeof dp);
	for(int i=0; i<cnt; i++) {
		if(none(dp[i]+1,x[i]-t-1))update(dp[i+1],x[i]);
		if(none(dp[i]+1,x[i]-1))update(dp[i+1],x[i]+t);
		if(i&&none(dp[i-1]+1,x[i]-t-1))update(dp[i+1],x[i-1]+t);
	} return none(dp[cnt]+1,n);
}
int main() {
	scanf("%d%s",&n,s+1);
	int pos=-1;
	for(int i=1; i<=n; i++) if(s[i]=='P')pos=x[cnt++]=i;
	if(cnt==1) {
		int L=0,R=0,lpos=-1,rpos=-1;;
		for(int i=pos-1; i; i--) if(s[i]=='*')L++,lpos=i;
		for(int i=pos+1; i<=n; i++) if(s[i]=='*')R++,rpos=i;
		if(L!=R)printf("%d %d\n",max(L,R),L>R?pos-lpos:rpos-pos);
		else printf("%d %d\n",L,min(pos-lpos,rpos-pos));
		return 0;
	} for(int i=1; i<=n; i++)sum[i]=sum[i-1]+(s[i]=='*');
	int l=0,r=n,ans=n;
	while(l<=r) {
		int mid=(l+r)/2;
		if(check(mid))r=mid-1,ans=mid;
		else l=mid+1;
	} return printf("%d %d\n",sum[n],ans),0;
}


#include<bits/stdc++.h>
#define LL long long
#define Debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
int n,cb=0,cd=0;
char s[1000005];
int d[1000005];
bool chk[1000005];
int q[1000005],l,r;
bool check(int x) {
	l=1;r=0;
	for(int i=1;i<=n;i++) if(s[i]=='B') q[++r]=i;
	for(int i=1,j;i<=cd;i++) {
		j=i; while(j<cd&&d[j+1]-x<=q[l]) j++;
		if(i==j) {
			if(q[l]>d[i]+x||q[l]<d[i]-x) return false;
			if(q[l]<d[i]) while(l<=r&&q[l]<d[i]) l++;
			else while(l<=r&&q[l]<=d[i]+x) l++;
		} else {
			int pre=j-1;
			if(chk[j]) while(l<=r&&q[l]<=d[pre]+x) l++;
			else while(l<=r&&q[l]<=d[j]+x) l++;
		} i=j;
		if(r<l) return true;
	}return false;
}
int main() {
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;i++) if(s[i]=='B') cb++;
	for(int i=1;i<=n;i++) if(s[i]=='D') d[++cd]=i;
	for(int i=1;i<=cd+1;i++)
	for(int j=d[i-1]+1;j<d[i];j++)
	if(s[i]=='B') chk[i]=1;
	if(cd>=2) {
		printf("%d ",cb);
		int l=1,r=n,ans;
		while(l<=r) {
			int mid=(l+r)>>1;
			if(check(mid)) ans=mid,r=mid-1;
			else l=mid+1;
		}printf("%d\n",ans);
	} else if(cd==1) {
		int tmp=0;
		for(int i=1;i<=n;i++) if(s[i]=='D') break; else tmp+=(s[i]=='B');
		printf("%d ",max(cb-tmp,tmp));
		int ps,ans=n;
		for(ps=1;ps<=n;ps++) if(s[ps]=='D') break;
		if((tmp<<1)==cb) {
			int pp=1;
			for(;pp<ps;pp++) if(s[pp]=='B') break;
			ans=min(ans,ps-pp);
			for(pp=n;pp>ps;pp--) if(s[pp]=='B') break;
			ans=min(ans,pp-ps);
		} else if((tmp<<1)<cb) {
			int pp;
			for(pp=n;pp>ps;pp--) if(s[pp]=='B') break;
			ans=min(ans,pp-ps);
		} else {
			int pp=1;
			for(;pp<ps;pp++) if(s[pp]=='B') break;
			ans=min(ans,ps-pp);
		}printf("%d",ans);
	} else puts("0 0");
	return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define Debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
int n,cb=0,cd=0;
char s[1000005];
int d[1000005];
bool chk[1000005];
int q[1000005],l,r;
bool check(int x) {
	l=1;r=0;
	for(int i=1;i<=n;i++) if(s[i]=='*') q[++r]=i;
	for(int i=1,j;i<=cd;i++) {
		j=i; while(j<cd&&d[j+1]-x<=q[l]) j++;
		if(i==j) {
			if(q[l]>d[i]+x||q[l]<d[i]-x) return false;
			if(q[l]<d[i]) while(l<=r&&q[l]<d[i]) l++;
			else while(l<=r&&q[l]<=d[i]+x) l++;
		} else {
			int pre=j-1;
			if(chk[j]) while(l<=r&&q[l]<=d[pre]+x) l++;
			else while(l<=r&&q[l]<=d[j]+x) l++;
		} i=j;
		if(r<l) return true;
	}return false;
}
int main() {
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;i++) if(s[i]=='*') cb++;
	for(int i=1;i<=n;i++) if(s[i]=='P') d[++cd]=i;
	for(int i=1;i<=cd+1;i++)
	for(int j=d[i-1]+1;j<d[i];j++)
	if(s[i]=='*') chk[i]=1;
	if(cd>=2) {
		printf("%d ",cb);
		int l=1,r=n,ans;
		while(l<=r) {
			int mid=(l+r)>>1;
			if(check(mid)) ans=mid,r=mid-1;
			else l=mid+1;
		}printf("%d\n",ans);
	} else if(cd==1) {
		int tmp=0;
		for(int i=1;i<=n;i++) if(s[i]=='P') break; else tmp+=(s[i]=='*');
		printf("%d ",max(cb-tmp,tmp));
		int ps,ans=n;
		for(ps=1;ps<=n;ps++) if(s[ps]=='P') break;
		if((tmp<<1)==cb) {
			int pp=1;
			for(;pp<ps;pp++) if(s[pp]=='*') break;
			ans=min(ans,ps-pp);
			for(pp=n;pp>ps;pp--) if(s[pp]=='*') break;
			ans=min(ans,pp-ps);
		} else if((tmp<<1)<cb) {
			int pp;
			for(pp=n;pp>ps;pp--) if(s[pp]=='*') break;
			ans=min(ans,pp-ps);
		} else {
			int pp=1;
			for(;pp<ps;pp++) if(s[pp]=='*') break;
			ans=min(ans,ps-pp);
		}printf("%d",ans);
	} else puts("0 0");
	return 0;
}


#include <bits/stdc++.h>
const int MAXN = 1e6+5;
using namespace std;
int n,a[MAXN],num,d[MAXN],b[MAXN];
int p[MAXN],dp[MAXN];
string s;
bool check(int k)
{
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=d[n];i++)
	{
		if(dp[i-1]>=p[i]-1 || b[dp[i-1]]==b[p[i]-1])
			dp[i]=max(dp[i],p[i]+k);
		if(dp[i-1]>=p[i]-k-1 || b[dp[i-1]]==b[p[i]-k-1])
			dp[i]=max(dp[i],p[i]);
		if(i>1 && (dp[i-2]>=p[i]-k+1 || b[dp[i-2]]==b[p[i]-k-1]))
			dp[i]=max(dp[i],p[i-1]+k);
		dp[i]=min(dp[i],n);
	}
	if(b[dp[d[n]]]==b[n])
		return 1;
	else return 0;
}
int main()
{
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='.')
			a[i+1]=0;
		else if(s[i]=='*')
			a[i+1]=1;
		else
		{
			a[i+1]=2;
			num++;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==2)
		{
			d[i]=d[i-1]+1;
			p[d[i]]=i;
		}
		else
			d[i]=d[i-1];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==1)
			b[i]=b[i-1]+1;
		else
			b[i]=b[i-1];
	}
	if(num==1)
	{
		int f=0,num1=0,num2=0,t1=n,t2=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]==2)
				f=i;
			else if(a[i]==1)
			{
				if(f==0)
				{
					num1++;
					t1=min(t1,i);
				}
				else
				{
					num2++;
					t2=max(t2,i);
				}
			}
		}
		if(num1>num2)
			cout<<num1<<" "<<f-t1<<endl;
		else if(num1<num2)
			cout<<num2<<" "<<t2-f<<endl;
		else
			cout<<num1<<" "<<min(f-t1,t2-f)<<endl;
		return 0;
	}
	int l=1,r=n,ans=n;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid))
		{
			r=mid-1;
			ans=mid;
		}
		else
			l=mid+1;
	}
	cout<<b[n]<<" "<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int len;
char s[1000010];
int sum[1000010];//骨头
int last,last2,num,wei;
int next_dog[1000010];
int next_gutou[1000010];
int inf=2e8;
int dp[1000010];
bool check(int w)//w秒吃完
{
	dp[0]=s[1]=='*'?1:next_gutou[1];//清理到了哪
	int q=0,last=0;
	for(int i=1;i<=len;i++)
	if(s[i]=='P')
	{
		++q;
		if(dp[q-1]<i)//背后还有骨头
		{
			if(i-w>dp[q-1]) return 0;
			dp[q]=next_gutou[i];
			//我往前前往后
			if(q>=2&&i-w<=dp[q-2])
			{
				int A=last+w;
				if(A>=len) dp[q]=len+1;
				else dp[q]=max(dp[q],next_gutou[A]);
			}
		}
		else
		{
			if(i+w>=len) dp[q]=len+1;
			else dp[q]=next_gutou[i+w];
		}
		last=i;
	}
	return dp[q]==len+1;
}
int main()
{
//	freopen("dogs.in","r",stdin);
//	freopen("dogs.out","w",stdout);
	scanf("%d",&len);
	scanf("%s",&s[1]);
	for(int i=1;i<=len;i++)
	{
		sum[i]=sum[i-1];
		if(s[i]=='*') sum[i]++;
	}
	last=last2=len+1;
	for(int i=len;i>=1;i--)
	{
		next_gutou[i]=last2;
		if(s[i]=='P') next_dog[i]=last,last=i,num++,wei=i;
		else if(s[i]=='*') last2=i;
	}
	if(num==1)
	{
		int A=sum[wei-1],B=sum[len]-sum[wei];
		if(A<B)
		{
			cout<<B<<' ';
			int T=0;
			for(int i=len;i>=1;i--)
			if(s[i]=='*')
			{
				T=i;
				break;
			}
			cout<<T-wei;
		}
		else if(A>B)
		{
			cout<<A<<" ";
			int T=0;
			for(int i=1;i<=wei;i++)
				if(s[i]=='*')
				{
				T=i;

				break;
				}
			cout<<wei-T;
		}
		else
		{
			cout<<A<<" ";
			if(!A) cout<<0<<'\n';
			else
			{
				int AA,BB;
				for(int i=1;i<=len;i++)
				if(s[i]=='*')
				{
					A=i;
					break;
				}
				for(int i=len;i>=1;i--)
				if(s[i]=='*')
				{
					B=i;
					break;
				}
				cout<<min(wei-A,B-wei);
			}
		}
	}
	else
	{
		cout<<sum[len]<<" ";
		int l=0,r=inf;
		int ans;
		while(l<=r)
		{
			int mid=l+r>>1;
			if(check(mid)) ans=mid,r=mid-1;
			else l=mid+1;
		}
		cout<<ans;
	}
	return 0;
}
/*
17
.*P*P**P**.**P...
*/
/*
17
.*P*P**P**.**P...
*/
/*
19
**P.*..*..P..*.*P**
*/
/*
10
..BBD.B.BD
*/
/*
20
..BBD.B.BD..BBD.B.BD
*/
/*
20
BBBBBBBDBBBDBBBDBBBB
*/
/*
23
BBBBDBBBDBBBBBBDBBBBBBB
*/


#include<bits/stdc++.h>
#define N 1000010
using namespace std;

int n, s[N], f[N]; char st[N]; vector<int> vec;

int S(int l, int r) {return l > r ? 0 : s[r] - s[l - 1];}

bool check(int w) {
    memset(f, 0, sizeof(f));
    for (int i = 1; i <= vec.size(); i++) {
        int pos = vec[i-1];
        if (!S(f[i-1] + 1, pos - 1)) f[i] = max(f[i], pos + w);
        if (!S(f[i-1] + 1, pos - w - 1)) f[i] = max(f[i], pos);
        if (i > 1 && S(f[i-2] + 1, pos - w - 1) == 0) f[i] = max(f[i], max(vec[i-2] + w, pos));
    }
    return S(f[vec.size()] + 1, n) == 0;
}

int main() {
    scanf("%d%s", &n, st + 1);
    for (int i = 1; i <= n; i++) {
        s[i] = s[i-1];
        if (st[i] == 'P') vec.push_back(i);
        else if (st[i] == '*') s[i]++;
    }
    if (vec.size() == 1) {
        int pos = vec[vec.size() - 1], sl = S(1, pos - 1), sr = S(pos + 1, n), l = 1, r = n;
        if (!sl && !sr) return puts("0 0"), 0;
        while (!S(1, l)) l++; while (!S(r, n)) r++;
        if (l > pos) return printf("%d %d\n", sr, r - pos), 0;
        if (r < pos) return printf("%d %d\n", sl, pos - l), 0;
        if (sl == sr) printf("%d %d\n", sl, min(pos - l, r - pos));
        else printf("%d %d\n", max(sl, sr), sl > sr ? pos - l : r - pos);
    }
	else {
        int l = 0, r = n + 5, ans;
        while (l <= r) {
        	int mid = (l + r) >> 1;
        	if (check(mid)) ans = mid, r = mid - 1;
        	else l = mid + 1;
		}
        printf("%d %d\n", S(1, n), ans);
    }
    return 0;
}


#include <bits/stdc++.h>
constexpr int N(1e6+11);
std::vector<int> A;
int f[N],_sum[N],n,m;
int sum(int i){return i<0?0:i>n?_sum[n]:_sum[i];}
bool check(int x)
{
	for(int i(1),pre;i<=m;++i)
	{
		pre=sum(A[i]-x-1);
		if(f[i-1]<pre)
			return false;
		if(f[i-1]>=_sum[n])
			return true;
		f[i]=pre==_sum[A[i]]?sum(A[i]+x):_sum[A[i]];
		if(i>=2&&f[i-2]>=pre)
			f[i]=std::max(f[i],sum(A[i-1]+x));
	}
	return f[m]>=_sum[n];
}
int main(void)
{
	static char S[N];
	scanf("%d%s",&n,S+1);
	std::vector<int> B;
	for(int i(1);i<=n;++i)
		if(S[i]=='P')
			A.push_back(i);
		else if(S[i]=='*')
			B.push_back(i),++_sum[i];
	std::partial_sum(_sum,_sum+n+1,_sum);
	if((m=A.size())==1)
	{
		int id(std::lower_bound(B.begin(),B.end(),A[0])-B.begin());
		int cnt(0),t(0);
		if(id)
			cnt=id,t=A[0]-B.front();
		if(int(B.size())-id>cnt||(int(B.size())-id==cnt&&B.back()-A[0]<t))
			cnt=B.size()-id,t=B.back()-A[0];
		printf("%d %d\n",cnt,t);
	}
	else
	{
		A.insert(A.begin(),0);
		int l(1),r(n),ans(n),mid;
		while(l<=r)
			check(mid=(l+r)/2)?ans=mid,r=mid-1:l=mid+1;
		printf("%d %d\n",B.size(),ans);
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cctype>
#include <cassert>
#include <iostream>
using std::cin; using std::cout; using std::endl;
#include <algorithm>
using std::sort; using std::min; using std::max;
#include <vector>
using std::vector;
#include <set>
using std::set;
#include <queue>
using std::queue; using std::priority_queue;
#include <utility>
using std::pair;
typedef pair<int, int> pii;
typedef long long LL;
typedef long double LD;
#define pass printf("%s : Line.%d\n", __FUNCTION__, __LINE__);

inline bool chmin(int &a, int b) { return a > b ? a = b, true : false; }
inline bool chmax(int &a, int b) { return a < b ? a = b, true : false; }

const int maxN = 1000000 + 233;
int n, m;
char s[maxN];
int pref[maxN];

int succ[maxN];

void initialize() {
	scanf("%d", &n);
	scanf("%s", s + 1);
	m = 0;
	for(int i = 1; i <= n; ++i) m += (s[i] == 'P');
	pref[0] = 0;
	for(int i = 1; i <= n; ++i) pref[i] = pref[i - 1] + (s[i] == '*');
	succ[n + 1] = maxN;
	s[n + 1] = '\0';
	for(int i = n; i >= 0; --i) {
		if(s[i + 1] == '*') succ[i] = i + 1;
		else succ[i] = succ[i + 1];
	}
}

pii spj() {
	int p = 0;
	for(int i = 1; i <= n; ++i) if(s[i] == 'P') p = i;
	int t1 = maxN, t2 = maxN;
	for(int i = p - 1; i >= 1; --i) if(s[i] == '*') t1 = i;
	for(int i = p + 1; i <= n; ++i) if(s[i] == '*') t2 = i;
	if(pref[n] - pref[p - 1] > pref[p - 1] - pref[0])
		return pii(pref[n] - pref[p - 1], t2 - p);
	else if(pref[n] - pref[p - 1] < pref[p - 1] - pref[0])
		return pii(pref[p - 1] - pref[0], p - t1);
	else return pii(pref[n] - pref[p - 1], std::min(t2 - p, p - t1));
}

vector<int> packs;
int f[maxN];

/*
58
..P.P*.P*.P...PPP...P*....*..*.**......*P.*P.....**P...*P*
*/

bool check(int range) {
//	printf("check : range = %d\n", range);
	for(int i = 0; i <= m + 5; ++i) f[i] = -1;
	f[0] = 0;
	for(int i = 0; i + 1 < (int)packs.size(); ++i) if(f[i] >= 0) {
		for(int d = 0; d < 2; ++d) {
			int lb = packs[i + 1];
			if(~d & 1) lb = packs[i + 1] - range;
			if(f[i] <= n && succ[f[i]] < lb) continue;

			int frb = std::max(f[i], packs[i + 1]);
			if(d & 1) chmax(frb, packs[i + 1] + range);
//			printf("case 1 : i = %d, d = %d, f[%d] -> %d\n", i, d, i + 1, frb);
			chmax(f[i + 1], frb);
		}
		if(i + 2 >= (int)packs.size()) continue;
		for(int d = 0; d < 4; ++d) {
			int lb = packs[i + 1];
			if(~d & 1) lb = packs[i + 1] - range;
			else if(~d & 2) chmin(lb, packs[i + 2] - range);
			if(f[i] <= n && succ[f[i]] < lb) continue;

			int mlb = std::max(packs[i + 1], f[i]);
			int mrb = packs[i + 2];
			if(~d & 2) chmin(mrb, packs[i + 2] - range);
			if(mlb <= n && succ[mlb] < mrb) continue;

			int frb = std::max(f[i], packs[i + 2]);
			if(d & 1) chmax(frb, packs[i + 1] + range);
			if(d & 2) chmax(frb, packs[i + 2] + range);
//			printf("case 2 : i = %d, d = %d, f[%d] -> %d\n", i, d, i + 2, frb);
			chmax(f[i + 2], frb);
		}
	}
//	printf("%d %d %d\n", packs[m], succ[packs[m]], f[m]);
//	system("pause");
	return f[m] >= packs[m] && (succ[packs[m]] > n || f[m] >= succ[packs[m]]);
}

pii solve() {
	packs.push_back(0);
	for(int i = 1; i <= n; ++i) if(s[i] == 'P') packs.push_back(i);
	assert(m == (int)packs.size() - 1);
	int L = 0, R = n;
	while(L < R) {
		int M = (L + R) >> 1;
		if(check(M)) R = M;
		else L = M + 1;
	}
	return pii(pref[n], L);
}

int main() {
	initialize();
	pii ans = m == 1 ? spj() : solve();
	printf("%d %d\n", ans.first, ans.second);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cctype>
#include <cassert>
#include <iostream>
using std::cin; using std::cout; using std::endl;
#include <algorithm>
using std::sort; using std::min; using std::max;
#include <vector>
using std::vector;
#include <set>
using std::set;
#include <queue>
using std::queue; using std::priority_queue;
#include <utility>
using std::pair;
typedef pair<int, int> pii;
typedef long long LL;
typedef long double LD;
#define pass printf("%s : Line.%d\n", __FUNCTION__, __LINE__);

inline bool chmin(int &a, int b) { return a > b ? a = b, true : false; }
inline bool chmax(int &a, int b) { return a < b ? a = b, true : false; }

const int maxN = 1000000 + 233;
int n, m;
char s[maxN];
int pref[maxN];

int succ[maxN];

void initialize() {
	scanf("%d", &n);
	scanf("%s", s + 1);
	m = 0;
	for(int i = 1; i <= n; ++i) m += (s[i] == 'P');
	pref[0] = 0;
	for(int i = 1; i <= n; ++i) pref[i] = pref[i - 1] + (s[i] == '*');
	succ[n + 1] = maxN;
	for(int i = n; i >= 0; --i) {
		if(s[i + 1] == '*') succ[i] = i + 1;
		else succ[i] = succ[i + 1];
	}
}

pii spj() {
	int p = 0;
	for(int i = 1; i <= n; ++i) if(s[i] == 'P') p = i;
	int t1 = maxN, t2 = maxN;
	for(int i = p - 1; i >= 1; --i) if(s[i] == '*') t1 = i;
	for(int i = p + 1; i <= n; ++i) if(s[i] == '*') t2 = i;
	if(pref[n] - pref[p - 1] > pref[p - 1] - pref[0])
		return pii(pref[n] - pref[p - 1], t2 - p);
	else if(pref[n] - pref[p - 1] < pref[p - 1] - pref[0])
		return pii(pref[p - 1] - pref[0], p - t1);
	else return pii(pref[n] - pref[p - 1], std::min(t2 - p, p - t1));
}

vector<int> packs;
int f[maxN];

/*
58
..P.P*.P*.P...PPP...P*....*..*.**......*P.*P.....**P...*P*
*/

bool check(int range) {
//	printf("check : range = %d\n", range);
	for(int i = 0; i <= m + 5; ++i) f[i] = -1;
	f[0] = 0;
	for(int i = 0; i + 1 < (int)packs.size(); ++i) if(f[i] >= 0) {
		for(int d = 0; d < 2; ++d) {
			int lb = packs[i + 1];
			if(~d & 1) lb = packs[i + 1] - range;
			if(f[i] <= n && succ[f[i]] < lb) continue;

			int frb = std::max(f[i], packs[i + 1]);
			if(d & 1) chmax(frb, packs[i + 1] + range);
//			printf("case 1 : i = %d, d = %d, f[%d] -> %d\n", i, d, i + 1, frb);
			chmax(f[i + 1], frb);
		}
		if(i + 2 >= (int)packs.size()) continue;
		for(int d = 0; d < 4; ++d) {
			int lb = packs[i + 1];
			if(~d & 1) lb = packs[i + 1] - range;
			else if(~d & 2) chmin(lb, packs[i + 2] - range);
			if(f[i] <= n && succ[f[i]] < lb) continue;

			int mlb = std::max(packs[i + 1], f[i]);
			int mrb = packs[i + 2];
			if(~d & 2) chmin(mrb, packs[i + 2] - range);
			if(mlb <= n && succ[mlb] < mrb) continue;

			int frb = std::max(f[i], packs[i + 2]);
			if(d & 1) chmax(frb, packs[i + 1] + range);
			if(d & 2) chmax(frb, packs[i + 2] + range);
//			printf("case 2 : i = %d, d = %d, f[%d] -> %d\n", i, d, i + 2, frb);
			chmax(f[i + 2], frb);
		}
	}
//	system("pause");
	return succ[packs[m]] > n || f[m] >= succ[packs[m]];
}

pii solve() {
	packs.push_back(0);
	for(int i = 1; i <= n; ++i) if(s[i] == 'P') packs.push_back(i);
	assert(m == (int)packs.size() - 1);
	int L = 0, R = n;
	while(L < R) {
		int M = (L + R) >> 1;
		if(check(M)) R = M;
		else L = M + 1;
	}
	return pii(pref[n], L);
}

int main() {
	initialize();
	pii ans = m == 1 ? spj() : solve();
	printf("%d %d\n", ans.first, ans.second);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cctype>
#include <cassert>
#include <iostream>
using std::cin; using std::cout; using std::endl;
#include <algorithm>
using std::sort; using std::min; using std::max;
#include <vector>
using std::vector;
#include <set>
using std::set;
#include <queue>
using std::queue; using std::priority_queue;
#include <utility>
using std::pair;
typedef pair<int, int> pii;
typedef long long LL;
typedef long double LD;
#define pass printf("%s : Line.%d\n", __FUNCTION__, __LINE__);

inline bool chmin(int &a, int b) { return a > b ? a = b, true : false; }
inline bool chmax(int &a, int b) { return a < b ? a = b, true : false; }

const int maxN = 1000000 + 233;
int n, m;
char s[maxN];
int pref[maxN];

int succ[maxN];

void initialize() {
	scanf("%d", &n);
	scanf("%s", s + 1);
	m = 0;
	for(int i = 1; i <= n; ++i) m += (s[i] == 'P');
	pref[0] = 0;
	for(int i = 1; i <= n; ++i) pref[i] = pref[i - 1] + (s[i] == '*');
	succ[n + 1] = maxN;
	for(int i = n; i >= 0; --i) {
		if(s[i + 1] == '*') succ[i] = i + 1;
		else succ[i] = succ[i + 1];
	}
}

pii spj() {
	int p = 0;
	for(int i = 1; i <= n; ++i) if(s[i] == 'P') p = i;
	int t1 = maxN, t2 = maxN;
	for(int i = p - 1; i >= 1; --i) if(s[i] == '*') t1 = i;
	for(int i = p + 1; i <= n; ++i) if(s[i] == '*') t2 = i;
	if(pref[n] - pref[p - 1] > pref[p - 1] - pref[0])
		return pii(pref[n] - pref[p - 1], t2 - p);
	else if(pref[n] - pref[p - 1] < pref[p - 1] - pref[0])
		return pii(pref[p - 1] - pref[0], p - t1);
	else return pii(pref[n] - pref[p - 1], std::min(t2 - p, p - t1));
}

vector<int> packs;
int f[maxN];

bool check(int range) {
//	printf("check : range = %d\n", range);
	for(int i = 0; i <= m + 5; ++i) f[i] = -1;
	f[0] = 0;
	for(int i = 0; i + 1 < (int)packs.size(); ++i) if(f[i] >= 0) {
		for(int d = 0; d < 2; ++d) {
			int lb = packs[i + 1];
			if(~d & 1) lb = packs[i + 1] - range;
			if(succ[f[i]] < lb) continue;

			int frb = std::max(f[i], packs[i + 1]);
			if(d & 1) chmax(frb, packs[i + 1] + range);
//			printf("case 1 : i = %d, d = %d, f[%d] -> %d\n", i, d, i + 1, frb);
			chmax(f[i + 1], frb);
		}
		if(i + 2 >= (int)packs.size()) continue;
		for(int d = 0; d < 4; ++d) {
			int lb = packs[i + 1];
			if(~d & 1) lb = packs[i + 1] - range;
			else if(~d & 2) chmin(lb, packs[i + 2] - range);
			if(succ[f[i]] < lb) continue;

			int mlb = std::max(packs[i + 1], f[i]);
			int mrb = packs[i + 2];
			if(~d & 2) chmin(mrb, packs[i + 2] - range);
			if(succ[mlb] < mrb) continue;

			int frb = std::max(f[i], packs[i + 2]);
			if(d & 1) chmax(frb, packs[i + 1] + range);
			if(d & 2) chmax(frb, packs[i + 2] + range);
//			printf("case 2 : i = %d, d = %d, f[%d] -> %d\n", i, d, i + 2, frb);
			chmax(f[i + 2], frb);
		}
	}
//	system("pause");
	return succ[f[m]] > n || f[m] >= succ[f[m]];
}

pii solve() {
	packs.push_back(0);
	for(int i = 1; i <= n; ++i) if(s[i] == 'P') packs.push_back(i);
	assert(m == (int)packs.size() - 1);
	int L = 0, R = n;
	while(L < R) {
		int M = (L + R) >> 1;
		if(check(M)) R = M;
		else L = M + 1;
	}
	return pii(pref[n], L);
}

int main() {
	initialize();
	pii ans = m == 1 ? spj() : solve();
	printf("%d %d\n", ans.first, ans.second);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cctype>
#include <cassert>
#include <iostream>
using std::cin; using std::cout; using std::endl;
#include <algorithm>
using std::sort; using std::min; using std::max;
#include <vector>
using std::vector;
#include <set>
using std::set;
#include <queue>
using std::queue; using std::priority_queue;
#include <utility>
using std::pair;
typedef pair<int, int> pii;
typedef long long LL;
typedef long double LD;
#define pass printf("%s : Line.%d\n", __FUNCTION__, __LINE__);

inline bool chmin(int &a, int b) { return a > b ? a = b, true : false; }
inline bool chmax(int &a, int b) { return a < b ? a = b, true : false; }

const int maxN = 1000000 + 233;
int n, m;
char s[maxN];
int pref[maxN];

int succ[maxN];

void initialize() {
	scanf("%d", &n);
	scanf("%s", s + 1);
	m = 0;
	for(int i = 1; i <= n; ++i) m += (s[i] == 'P');
	pref[0] = 0;
	for(int i = 1; i <= n; ++i) pref[i] = pref[i - 1] + (s[i] == '*');
	succ[n + 1] = maxN;
	s[n + 1] = '\0';
	for(int i = n; i >= 0; --i) {
		if(s[i + 1] == '*') succ[i] = i + 1;
		else succ[i] = succ[i + 1];
	}
}

pii spj() {
	int p = 0;
	for(int i = 1; i <= n; ++i) if(s[i] == 'P') p = i;
	int t1 = maxN, t2 = maxN;
	for(int i = p - 1; i >= 1; --i) if(s[i] == '*') t1 = i;
	for(int i = p + 1; i <= n; ++i) if(s[i] == '*') t2 = i;
	if(pref[n] - pref[p - 1] > pref[p - 1] - pref[0])
		return pii(pref[n] - pref[p - 1], t2 - p);
	else if(pref[n] - pref[p - 1] < pref[p - 1] - pref[0])
		return pii(pref[p - 1] - pref[0], p - t1);
	else return pii(pref[n] - pref[p - 1], std::min(t2 - p, p - t1));
}

vector<int> packs;
int f[maxN];

/*
58
..P.P*.P*.P...PPP...P*....*..*.**......*P.*P.....**P...*P*
*/

int last_pos;

bool check(int range) {
//	printf("check : range = %d\n", range);
	for(int i = 0; i <= m + 5; ++i) f[i] = -1;
	f[0] = 0;
	for(int i = 0; i + 1 < (int)packs.size(); ++i) if(f[i] >= 0) {
		for(int d = 0; d < 2; ++d) {
			int lb = packs[i + 1];
			if(~d & 1) lb = packs[i + 1] - range;
			if(f[i] <= n && succ[f[i]] < lb) continue;

			int frb = std::max(f[i], packs[i + 1]);
			if(d & 1) chmax(frb, packs[i + 1] + range);
//			printf("case 1 : i = %d, d = %d, f[%d] -> %d\n", i, d, i + 1, frb);
			chmax(f[i + 1], frb);
		}
		if(i + 2 >= (int)packs.size()) continue;
		for(int d = 0; d < 4; ++d) {
			int lb = packs[i + 1];
			if(~d & 1) lb = packs[i + 1] - range;
			else if(~d & 2) chmin(lb, packs[i + 2] - range);
			if(f[i] <= n && succ[f[i]] < lb) continue;

			int mlb = std::max(packs[i + 1], f[i]);
			int mrb = packs[i + 2];
			if(~d & 2) chmin(mrb, packs[i + 2] - range);
			if(mlb <= n && succ[mlb] < mrb) continue;

			int frb = std::max(f[i], packs[i + 2]);
			if(d & 1) chmax(frb, packs[i + 1] + range);
			if(d & 2) chmax(frb, packs[i + 2] + range);
//			printf("case 2 : i = %d, d = %d, f[%d] -> %d\n", i, d, i + 2, frb);
			chmax(f[i + 2], frb);
		}
	}
//	printf("%d %d %d\n", packs[m], succ[packs[m]], f[m]);
//	system("pause");
	return f[m] >= last_pos;
}

pii solve() {
	packs.push_back(0);
	for(int i = 1; i <= n; ++i) if(s[i] == 'P') packs.push_back(i);
	assert(m == (int)packs.size() - 1);
	for(int i = 1; i <= n; ++i) if(s[i] == '*') last_pos = i;
	int L = 0, R = n;
	while(L < R) {
		int M = (L + R) >> 1;
		if(check(M)) R = M;
		else L = M + 1;
	}
	return pii(pref[n], L);
}

int main() {
	initialize();
	pii ans = m == 1 ? spj() : solve();
	printf("%d %d\n", ans.first, ans.second);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pb emplace_back
#define mkp make_pair
#define rint register int
#define INF ((1ll << 60) - 1)
#define FI(n) FastIO::read(n)
#define FO(n) FastIO::write(n)
#define Pair pair < int, int >
#define mst(a,b) memset(a,b,sizeof(a))
#define foR(i, k, j) for(rint i = (k); i >= (j); i--)
#define For(i, k, j) for(rint i = (k); i <= (j); i++)
#define Foe(i, u) for(rint i = lst[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout)
//#define int long long
const int P = 1000000007; //
using namespace std;
inline void ckmax(int &a, int b) {a = max(a, b);}
inline void ckmin(int &a, int b) {a = min(a, b);}
inline void mulmod(int &a, int b) {a = 1ll * a * b % P;}
inline void addmod(int &a, int b) {int t = a + b; a = (t >= P ? t - P : t); }
inline int ksm(int a, int b) {int ans=1; for(;b;b>>=1) {if(b&1) ans=1ll*ans*a%P;a=1ll*a*a%P;}return ans;}
inline int inv(int a) {return ksm(a, P-2);}

inline void printarray(int *a, int n) {For(i, 1, n) fprintf(stderr, "%d ", a[i]); fprintf(stderr, "\n");}
namespace FastIO {
    const int SIZE=1<<16; char buf[SIZE], obuf[SIZE], str[64]; int bi=SIZE, bn=SIZE, opt;
    int read(char *s) {
        while (bn) {for (;bi<bn&&buf[bi]<=' ';bi++);if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}
        int sn=0;while (bn) {for (;bi<bn&&buf[bi]>' ';bi++) s[sn++]=buf[bi];if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}s[sn]=0;return sn;
    }
    bool read(int& x) {if(x)x=0;int bf=0,n=read(str); if(!n) return 0; int i=0; if (str[i]=='-') bf=1,i=1; for(x=0;i<n;i++) x=x*10+str[i]-'0'; if(bf) x=-x; return 1;}
    void write(int x) {
        if(!x) obuf[opt++] = '0'; else {if(x<0) obuf[opt++]='-',x=-x;int sn=0; while(x)str[sn++]=x%10+'0',x/=10;for (int i=sn-1;i>=0;i--) obuf[opt++]=str[i];}
        if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}
    }
    void write(char x) {obuf[opt++]=x;if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}}
    void Fflush() { if (opt) fwrite(obuf, 1, opt, stdout); opt=0;}
};
const int MAXN = 1e6 + 5;
char s[MAXN]; int n, pos[MAXN], m, a[MAXN], f[MAXN];
bool c(int l, int r) {
	if(l > r - 1) return 1;
	return a[min(r - 1, n)] - a[max(l, 0)] <= 0;
}
int check(int mid) {
	cerr << "mid = " << mid <<  endl;
	mst(f, 0);
	f[0] = -mid;
	For(i, 1, m) {
		if(c(f[i - 1], pos[i] - mid)) ckmax(f[i], pos[i]);
		if(c(f[i - 1], pos[i])) ckmax(f[i], pos[i] + mid);
		if(i > 1) {
			if(c(f[i - 2], pos[i] - mid)) ckmax(f[i], pos[i - 1] + mid);
		}
//		cerr << i << ' ' << f[i] << endl;
		if(f[i] >= n) return 1;
	}

	return c(f[m], n + 1);
}
signed main()
{
    #ifndef ONLINE_JUDGE
        file("pro");
    #endif
    FI(n); FI(s + 1);
    For(i, 1, n) {
    	a[i] = a[i - 1] + (s[i] == '*');
    	if(s[i] == 'P') pos[++m] = i;
	}
	if(m == 1) {
		if(a[n] - a[pos[1]] > a[pos[1]]) printf("%d %d\n", a[n] - a[pos[1]], n - pos[1]);
		else if(a[n] - a[pos[1]] < a[pos[1]]) printf("%d %d\n", a[pos[1]], pos[1] - 1);
		else printf("%d %d\n", a[pos[1]], min(n - pos[1], pos[1] - 1));
		return 0;
	}
	printf("%d ", a[n]);
	int l = 1, r = n, res = 0;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(check(mid)) {
			r = mid - 1, res = mid;
		} else {
			l = mid + 1;
		}
	}
	cout << res << endl;
    return FastIO::Fflush(), 0;
}
/*

4 7 1
2 1 8
2 4 2
4 3 2
3 2 8
2 3 5
4 3 1
2 4 5
2 9
*/


#include<bits/stdc++.h>
#define ll long long
#define pb emplace_back
#define mkp make_pair
#define rint register int
#define INF ((1 << 30) - 1)
#define FI(n) FastIO::read(n)
#define FO(n) FastIO::write(n)
#define Pair pair < int, int >
#define mst(a,b) memset(a,b,sizeof(a))
#define foR(i, k, j) for(rint i = (k); i >= (j); i--)
#define For(i, k, j) for(rint i = (k); i <= (j); i++)
#define Foe(i, u) for(rint i = lst[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout)
//#define int long long
const int P = 1000000007; //
using namespace std;
inline void ckmax(int &a, int b) {a = max(a, b);}
inline void ckmin(int &a, int b) {a = min(a, b);}
inline void mulmod(int &a, int b) {a = 1ll * a * b % P;}
inline void addmod(int &a, int b) {int t = a + b; a = (t >= P ? t - P : t); }
inline int ksm(int a, int b) {int ans=1; for(;b;b>>=1) {if(b&1) ans=1ll*ans*a%P;a=1ll*a*a%P;}return ans;}
inline int inv(int a) {return ksm(a, P-2);}

inline void printarray(int *a, int n) {For(i, 1, n) fprintf(stderr, "%d ", a[i]); fprintf(stderr, "\n");}
namespace FastIO {
    const int SIZE=1<<16; char buf[SIZE], obuf[SIZE], str[64]; int bi=SIZE, bn=SIZE, opt;
    int read(char *s) {
        while (bn) {for (;bi<bn&&buf[bi]<=' ';bi++);if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}
        int sn=0;while (bn) {for (;bi<bn&&buf[bi]>' ';bi++) s[sn++]=buf[bi];if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}s[sn]=0;return sn;
    }
    bool read(int& x) {if(x)x=0;int bf=0,n=read(str); if(!n) return 0; int i=0; if (str[i]=='-') bf=1,i=1; for(x=0;i<n;i++) x=x*10+str[i]-'0'; if(bf) x=-x; return 1;}
    void write(int x) {
        if(!x) obuf[opt++] = '0'; else {if(x<0) obuf[opt++]='-',x=-x;int sn=0; while(x)str[sn++]=x%10+'0',x/=10;for (int i=sn-1;i>=0;i--) obuf[opt++]=str[i];}
        if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}
    }
    void write(char x) {obuf[opt++]=x;if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}}
    void Fflush() { if (opt) fwrite(obuf, 1, opt, stdout); opt=0;}
};
const int MAXN = 1e6 + 5;
char s[MAXN]; int n, pos[MAXN], m, a[MAXN], f[MAXN];
bool c(int l, int r) {
	if(l > r - 1) return 1;
	return a[min(r - 1, n)] - a[max(l, 0)] <= 0;
}
int check(int mid) {
//	cerr << "mid = " << mid <<  endl;
	mst(f, 0);
	f[0] = -mid;
	For(i, 1, m) {
		if(c(f[i - 1], pos[i] - mid)) ckmax(f[i], pos[i]);
		if(c(f[i - 1], pos[i])) ckmax(f[i], pos[i] + mid);
		if(i > 1) {
			if(c(f[i - 2], pos[i] - mid)) ckmax(f[i], pos[i - 1] + mid);
		}
		cerr << i << ' ' << f[i] << endl;
		if(f[i] >= n) return 1;
	}

	return c(f[m], n + 1);
}
signed main()
{
    #ifndef ONLINE_JUDGE
        file("pro");
    #endif
    FI(n); FI(s + 1);
    For(i, 1, n) {
    	a[i] = a[i - 1] + (s[i] == '*');
    	if(s[i] == 'P') pos[++m] = i;
	}
	if(m == 1) {
		int lst = INF, pre = -INF;
		For(i, pos[1], n) if(pos[1] <= i && s[i] == '*') lst = i;
		foR(i, pos[1], 1) if(pos[1] >= i && s[i] == '*') pre = i;
		if(a[n] - a[pos[1]] > a[pos[1]]) printf("%d %d\n", a[n] - a[pos[1]], lst - pos[1]);
		else if(a[n] - a[pos[1]] < a[pos[1]]) printf("%d %d\n", a[pos[1]], pos[1] - pre);
		else printf("%d %d\n", a[pos[1]], min(lst - pos[1], pos[1] - pre));
		return 0;
	}
	printf("%d ", a[n]);
	int l = 1, r = n, res = 0;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(check(mid)) {
			r = mid - 1, res = mid;
		} else {
			l = mid + 1;
		}
	}
	cout << res << endl;
    return FastIO::Fflush(), 0;
}
/*

4 7 1
2 1 8
2 4 2
4 3 2
3 2 8
2 3 5
4 3 1
2 4 5
2 9
*/


#include<bits/stdc++.h>
#define ll long long
#define pb emplace_back
#define mkp make_pair
#define rint register int
#define INF ((1 << 30) - 1)
#define FI(n) FastIO::read(n)
#define FO(n) FastIO::write(n)
#define Pair pair < int, int >
#define mst(a,b) memset(a,b,sizeof(a))
#define foR(i, k, j) for(rint i = (k); i >= (j); i--)
#define For(i, k, j) for(rint i = (k); i <= (j); i++)
#define Foe(i, u) for(rint i = lst[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout)
//#define int long long
const int P = 1000000007; //
using namespace std;
inline void ckmax(int &a, int b) {a = max(a, b);}
inline void ckmin(int &a, int b) {a = min(a, b);}
inline void mulmod(int &a, int b) {a = 1ll * a * b % P;}
inline void addmod(int &a, int b) {int t = a + b; a = (t >= P ? t - P : t); }
inline int ksm(int a, int b) {int ans=1; for(;b;b>>=1) {if(b&1) ans=1ll*ans*a%P;a=1ll*a*a%P;}return ans;}
inline int inv(int a) {return ksm(a, P-2);}

inline void printarray(int *a, int n) {For(i, 1, n) fprintf(stderr, "%d ", a[i]); fprintf(stderr, "\n");}
namespace FastIO {
    const int SIZE=1<<16; char buf[SIZE], obuf[SIZE], str[64]; int bi=SIZE, bn=SIZE, opt;
    int read(char *s) {
        while (bn) {for (;bi<bn&&buf[bi]<=' ';bi++);if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}
        int sn=0;while (bn) {for (;bi<bn&&buf[bi]>' ';bi++) s[sn++]=buf[bi];if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}s[sn]=0;return sn;
    }
    bool read(int& x) {if(x)x=0;int bf=0,n=read(str); if(!n) return 0; int i=0; if (str[i]=='-') bf=1,i=1; for(x=0;i<n;i++) x=x*10+str[i]-'0'; if(bf) x=-x; return 1;}
    void write(int x) {
        if(!x) obuf[opt++] = '0'; else {if(x<0) obuf[opt++]='-',x=-x;int sn=0; while(x)str[sn++]=x%10+'0',x/=10;for (int i=sn-1;i>=0;i--) obuf[opt++]=str[i];}
        if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}
    }
    void write(char x) {obuf[opt++]=x;if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}}
    void Fflush() { if (opt) fwrite(obuf, 1, opt, stdout); opt=0;}
};
const int MAXN = 1e6 + 5;
char s[MAXN]; int n, pos[MAXN], m, a[MAXN], f[MAXN];
bool c(int l, int r) {
	if(l > r - 1) return 1;
	return a[min(r - 1, n)] - a[max(l, 0)] <= 0;
}
int check(int mid) {
//	cerr << "mid = " << mid <<  endl;
	mst(f, 0);
	f[0] = -mid;
	For(i, 1, m) {
		if(c(f[i - 1], pos[i] - mid)) ckmax(f[i], pos[i]);
		if(c(f[i - 1], pos[i])) ckmax(f[i], pos[i] + mid);
		if(i > 1) {
			if(c(f[i - 2], pos[i] - mid)) ckmax(f[i], pos[i - 1] + mid);
		}
//		cerr << i << ' ' << f[i] << endl;
		if(f[i] >= n) return 1;
	}

	return c(f[m], n + 1);
}
signed main()
{
    #ifndef ONLINE_JUDGE
        file("pro");
    #endif
    FI(n); FI(s + 1);
    For(i, 1, n) {
    	a[i] = a[i - 1] + (s[i] == '*');
    	if(s[i] == 'P') pos[++m] = i;
	}
	if(m == 1) {
		int lst = INF, pre = -INF;
		For(i, pos[1], n) if(pos[1] <= i && s[i] == '*') lst = i;
		foR(i, pos[1], 1) if(pos[1] >= i && s[i] == '*') pre = i;
		if(a[n] - a[pos[1]] > a[pos[1]]) printf("%d %d\n", a[n] - a[pos[1]], lst - pos[1]);
		else if(a[n] - a[pos[1]] < a[pos[1]]) printf("%d %d\n", a[pos[1]], pos[1] - pre);
		else printf("%d %d\n", a[pos[1]], min(lst - pos[1], pos[1] - pre));
		return 0;
	}
	printf("%d ", a[n]);
	int l = 1, r = n, res = 0;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(check(mid)) {
			r = mid - 1, res = mid;
		} else {
			l = mid + 1;
		}
	}
	cout << res << endl;
    return FastIO::Fflush(), 0;
}
/*

4 7 1
2 1 8
2 4 2
4 3 2
3 2 8
2 3 5
4 3 1
2 4 5
2 9
*/


#include <bits/stdc++.h>
constexpr int N(1e6+11);
std::vector<int> A;
int f[N],_sum[N],n,m;
int sum(int i){return i<0?0:i>n?_sum[n]:_sum[i];}
bool check(int x)
{
	for(int i(1),pre;i<=m;++i)
	{
		pre=sum(A[i]-x-1);
		if(f[i-1]<pre)
			return false;
		if(f[i-1]>=_sum[n])
			return true;
		f[i]=f[i-1]>=_sum[A[i]]?sum(A[i]+x):_sum[A[i]];
		if(i>=2&&f[i-2]>=pre)
			f[i]=std::max(f[i],sum(A[i-1]+x));
	}
	return f[m]>=_sum[n];
}
int main(void)
{
	static char S[N];
	scanf("%d%s",&n,S+1);
	std::vector<int> B;
	for(int i(1);i<=n;++i)
		if(S[i]=='P')
			A.push_back(i);
		else if(S[i]=='*')
			B.push_back(i),++_sum[i];
	std::partial_sum(_sum,_sum+n+1,_sum);
	if((m=A.size())==1)
	{
		int id(std::lower_bound(B.begin(),B.end(),A[0])-B.begin());
		int cnt(0),t(0);
		if(id)
			cnt=id,t=A[0]-B.front();
		if(int(B.size())-id>cnt||(int(B.size())-id==cnt&&B.back()-A[0]<t))
			cnt=B.size()-id,t=B.back()-A[0];
		printf("%d %d\n",cnt,t);
	}
	else
	{
		A.insert(A.begin(),0);
		int l(1),r(n),ans(n),mid;
		while(l<=r)
			check(mid=(l+r)/2)?ans=mid,r=mid-1:l=mid+1;
		printf("%d %d\n",B.size(),ans);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int len;
char s[1000010];
int sum[1000010];//骨头
int last,last2,num,wei;
int next_dog[1000010];
int next_gutou[1000010];
int inf=2e8;
bool check(int w)//w秒吃完
{
	bool flag=0;//任务有没有完成
	int las=s[1]=='*'?1:next_gutou[1];//清理到了哪
	int mmax=0;
	for(int i=1;i<=len;i++)
	if(s[i]=='P')
	{
		int L=i-1;
		int R=len-i;
		if(flag) mmax=max(mmax,min(L,R));
		else
		{
			if(las<i)//前面还有骨头
			{
				int ii=next_dog[i];
				int jj=next_gutou[i];
				if(ii==len+1)//前面无狗
				{
					if(jj!=len+1) return 0;//清理失败
					mmax=max(mmax,L);//往回走
				}
				else
				{
					if(jj<ii)/*中间有骨头*/
					{
						if(R<=w) flag=1,mmax=max(mmax,max(R,ii-1)),i=ii;//往外走
						else las=jj,mmax=max(mmax,L);
					}
					else //中间无骨头
					{
						mmax=max(mmax,L);
						las=jj;
					}
				}
			}
			else
			{
				if(R<=w) flag=1,mmax=max(mmax,R);
				else mmax=max(mmax,L);
			}
		}
	}
	return mmax<=w;
}
int main()
{
	scanf("%d",&len);
	scanf("%s",&s[1]);
	for(int i=1;i<=len;i++)
	{
		sum[i]=sum[i-1];
		if(s[i]=='*') sum[i]++;
	}
	last=last2=len+1;
	for(int i=len;i>=1;i--)
	{
		if(s[i]=='P') next_dog[i]=last,last=i,num++,wei=i;
		else if(s[i]=='*') last2=i;
		next_gutou[i]=last2;
	}
	if(num==1)
	{
		int A=sum[wei-1],B=sum[len]-sum[wei];
		if(A<B) cout<<B<<' '<<len-wei;
		else if(A>B) cout<<A<<" "<<wei-1;
		else cout<<A<<" "<<min(len-wei,wei-1);
	}
	else
	{
		cout<<sum[len]<<" ";
		int l=0,r=inf;
		int ans;
		while(l<=r)
		{
			int mid=l+r>>1;
			if(check(mid)) ans=mid,r=mid-1;
			else l=mid+1;
		}
		cout<<ans;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define N 1001001

int n, a[N], an, b[N], bn;
char s[N];

bool ok(int limit) {
	int last = 0;
	for (int i = 1; i <= an && last < bn; i ++) {
		if (b[last+1] < a[i]) {
			int d = a[i] - b[last+1];
			if (d > limit) return 0;
			int j = (i < an && a[i+1] <= b[last+1] + limit) ? i + 1 : i;
			if (j == i) {
				last = lower_bound(b + 1, b + bn + 1, a[i]) - b - 1;
				continue;
			}
			int k = lower_bound(b + 1, b + bn + 1, a[i]) - b;
			if (k <= bn && b[k] < a[i+1]) {
				last = lower_bound(b + 1, b + bn + 1, a[i] + limit + 1) - b - 1;
				i ++;
			}
			else last = lower_bound(b + 1, b + bn + 1, a[i]) - b - 1;
		}
		else last = lower_bound(b + 1, b + bn + 1, a[i] + limit + 1) - b - 1;
	}
	return last == bn;
}

int main() {
//	freopen("d.in", "r", stdin);
	scanf("%d %s", &n, s + 1);
	for (int i = 1; i <= n; i ++) {
		if (s[i] == 'P') a[++an] = i;
		else if (s[i] == '*') b[++bn] = i;
	}
	if (an == 1) {
		int x = a[1];
		int cntl = 0, dl, cntr = 0, dr;
		for (int i = x - 1; i >= 1; i --) if (s[i] == '*') cntl ++, dl = x - i;
		for (int i = x + 1; i <= n; i ++) if (s[i] == '*') cntr ++, dr = i - x;
		if (cntl > cntr) printf("%d %d\n", cntl, dl);
		else if (cntl < cntr) printf("%d %d\n", cntr, dr);
		else printf("%d %d\n", cntl, min(dl, dr));
		return 0;
	}
	int st = 0, en = n;
	while (en - st > 1) {
		int mid = st + en >> 1;
		if (ok(mid)) en = mid;
		else st = mid;
	}
	printf("%d %d\n", bn, en);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define N 1001001

int n, a[N], an, b[N], bn, f[N];
char s[N];

bool ok(int limit) {
	memset(f, 0, sizeof f);
	for (int i = 1; i <= an; i ++) {
		int last = f[i-1];
		if (b[last+1] < a[i]) {
			int d = a[i] - b[last+1];
			if (d > limit && f[i] <= last) return 0;
			f[i] = max(f[i], lower_bound(b + 1, b + bn + 1, a[i]) - b - 1);
			if (i < an && a[i+1] <= b[last+1] + limit) {
				f[i+1] = max(f[i+1], lower_bound(b + 1, b + bn + 1, a[i] + limit + 1) - b - 1);
			}
		}
		else f[i] = max(f[i], lower_bound(b + 1, b + bn + 1, a[i] + limit + 1) - b - 1);
		if (f[i] >= bn) return 1;
	}
	return f[an] >= bn;
}

int main() {
//	freopen("d.in", "r", stdin);
	scanf("%d %s", &n, s + 1);
	for (int i = 1; i <= n; i ++) {
		if (s[i] == 'P') a[++an] = i;
		else if (s[i] == '*') b[++bn] = i;
	}
	if (an == 1) {
		int x = a[1];
		int cntl = 0, dl, cntr = 0, dr;
		for (int i = x - 1; i >= 1; i --) if (s[i] == '*') cntl ++, dl = x - i;
		for (int i = x + 1; i <= n; i ++) if (s[i] == '*') cntr ++, dr = i - x;
		if (cntl > cntr) printf("%d %d\n", cntl, dl);
		else if (cntl < cntr) printf("%d %d\n", cntr, dr);
		else printf("%d %d\n", cntl, min(dl, dr));
		return 0;
	}
	int st = 0, en = n;
	while (en - st > 1) {
		int mid = st + en >> 1;
		if (ok(mid)) en = mid;
		else st = mid;
	}
	printf("%d %d\n", bn, en);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define N 1001001

int n, a[N], an, b[N], bn;
char s[N];

bool ok(int limit) {
	int last = 0;
	for (int i = 1; i <= an && last < bn; i ++) {
		if (b[last+1] < a[i]) {
			int d = a[i] - b[last+1];
			if (d > limit) return 0;
			int j = lower_bound(a + 1, a + an + 1, b[last+1] + limit + 1) - a - 1;
			if (j == i) {
				last = lower_bound(b + 1, b + bn + 1, a[i]) - b - 1;
				continue;
			}
			last = lower_bound(b + 1, b + bn + 1, a[i] + limit + 1) - b - 1;
			i ++;
		}
		else last = lower_bound(b + 1, b + bn + 1, a[i] + limit + 1) - b - 1;
	}
	return last == bn;
}

int main() {
//	freopen("d.in", "r", stdin);
	scanf("%d %s", &n, s + 1);
	for (int i = 1; i <= n; i ++) {
		if (s[i] == 'P') a[++an] = i;
		else if (s[i] == '*') b[++bn] = i;
	}
	if (an == 1) {
		int x = a[1];
		int cntl = 0, dl, cntr = 0, dr;
		for (int i = x - 1; i >= 1; i --) if (s[i] == '*') cntl ++, dl = x - i;
		for (int i = x + 1; i <= n; i ++) if (s[i] == '*') cntr ++, dr = i - x;
		if (cntl > cntr) printf("%d %d\n", cntl, dl);
		else if (cntl < cntr) printf("%d %d\n", cntr, dr);
		else printf("%d %d\n", cntl, min(dl, dr));
		return 0;
	}
	int st = 0, en = n;
	while (en - st > 1) {
		int mid = st + en >> 1;
		if (ok(mid)) en = mid;
		else st = mid;
	}
	printf("%d %d\n", bn, en);
	return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define ll long long
#define mp make_pair
#define pii pair<int,int>
using namespace std;
const int maxn=1000005;
string s;
int n,m;
vector<int> pos;
int sum[maxn],dp[maxn];
void prework()
{
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='*')
        sum[i]=sum[i-1]+1;
        else
        sum[i]=sum[i-1];
        if(s[i]=='P')
        pos.pb(i);
    }
    m=pos.size();
}
void straight()
{
    int sta=pos[0];
    int sumlef=0,timlef=0,k=0,sumrig=0,timrig=0;
    for(int i=sta-1;i>=1;i--)
    {
        k++;
        if(s[i]=='*')
        {
            sumlef++;
            timlef=k;
        }
    }
    k=0;
    for(int i=sta+1;i<=n;i++)
    {
        k++;
        if(s[i]=='*')
        {
            sumrig++;
            timrig=k;
        }
    }
    if(sumlef<sumrig || (sumlef==sumrig && timrig<timlef))
    cout<<sumrig<<" "<<timrig<<endl;
    else
    cout<<sumlef<<" "<<timlef<<endl;
}
inline bool nothing(int l,int r)
{
    return (r<l || !(sum[r]-sum[l-1]));
}
bool check(int tim)
{
    memset(dp,0,sizeof(dp));
    for(int i=0;i<m;i++)
    {
        if(nothing(dp[i]+1,pos[i]-tim-1))
        dp[i+1]=max(dp[i+1],pos[i]);

        if(nothing(dp[i]+1,pos[i]-1))
        dp[i+1]=max(dp[i+1],pos[i]+tim);

        if(i>=1 && nothing(dp[i-1]+1,pos[i]-tim-1) && pos[i]-tim<pos[i-1])
        dp[i+1]=max(dp[i+1],pos[i-1]+tim);
    }
    if(nothing(dp[m]+1,n))
    return 1;
    return 0;
}
void binary()
{
    int l=0,r=n,mid,ans=0;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(check(mid))
        {
            r=mid-1;
            ans=mid;
        }
        else
        l=mid+1;
    }
    cout<<sum[n]<<" "<<ans<<endl;
}
int main()
{
    cin>>n>>s;
    s=" "+s;
    prework();
    if(m==1)
    straight();
    else
    binary();
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int n;
char s[2000010];
int sf[2000010];
int pos[2000010];
int dp[2000010];
int tot = 0;
int check(int o)
{
	memset(dp, 0, sizeof(dp));
	for (int i = 1; i <= tot; ++ i)
	{
		if(sf[pos[i] - o - 1] - sf[dp[i - 1]] <= 0)
		dp[i] = max(dp[i], pos[i]);
		if(sf[pos[i] - 1] - sf[dp[i - 1]] <= 0)
		dp[i] = max(dp[i], pos[i] + o);
		if(i > 1 && sf[pos[i] - o - 1] - sf[dp[i - 2]] <= 0)
		dp[i] = max(dp[i], pos[i - 1] + o);
	}
	return (sf[n] - sf[dp[tot]] <= 0);
}
int main()
{
	scanf("%d", &n);
	scanf("%s", s + 1);
	for (int i = 1; i <= n; ++ i)
	{
		sf[i] = sf[i - 1];
		if(s[i] == 'P')
		{
			pos[++ tot] = i;
		}
		if(s[i] == '*')
		{
			++ sf[i];
		}
	}
	for (int i = n + 1; i <= 2e6; ++ i)
	sf[i] = sf[i - 1];
	if(tot == 1)
	{
		int now = 0;
		int timesl = 0, totl = 0;
		for (int i = pos[1] - 1; i; -- i)
		{
			++ now;
			if(s[i] == '*')
			{
				++ totl;
				timesl = now;
			}
		}
		int timesr = 0, totr = 0;
		now = 0;
		for (int i = pos[1] + 1; i <= n; ++ i)
		{
			++ now;
			if(s[i] == '*')
			{
				++ totr;
				timesr = now;
			}
		}
		printf("%d\n", max(totl, totr));
		if(totl < totr)
		printf("%d\n", timesr);
		else
		if(totl > totr)
		printf("%d\n", timesl);
		else
		printf("%d\n", min(timesl, timesr));
	}
	else
	{
		printf("%d\n", sf[n]);
		int l = 1, r = n;
		while(l < r)
		{
			int mid = (l + r) >> 1;
			if(check(mid))r = mid;
			else l = mid + 1;
		}
		printf("%d\n", l);
	}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int n;
char s[1000010];
int sf[1000010];
int pos[1000010];
int dp[1000010];
int tot = 0;
int check(int o)
{
	memset(dp, 0, sizeof(dp));
	for (int i = 1; i <= tot; ++ i)
	{
		if(sf[pos[i] - o - 1] - sf[pos[i - 1]] <= 0)
		dp[i] = max(dp[i], pos[i]);
		if(sf[pos[i] - 1] - sf[pos[i - 1]] <= 0)
		dp[i] = max(dp[i], pos[i] + o);
		if(i > 1 && sf[pos[i] - o - 1] - sf[dp[i - 2]] <= 0)
		dp[i] = max(dp[i], pos[i - 1] + o);
	}
	return (sf[n] - sf[dp[tot]] <= 0);
}
int main()
{
	scanf("%d", &n);
	scanf("%s", s + 1);
	for (int i = 1; i <= n; ++ i)
	{
		sf[i] = sf[i - 1];
		if(s[i] == 'P')
		{
			pos[++ tot] = i;
		}
		if(s[i] == '*')
		{
			++ sf[i];
		}
	}
	for (int i = n + 1; i <= 1e6; ++ i)
	sf[i] = sf[i - 1];
	if(tot == 1)
	{
		int now = 0;
		int timesl = 0, totl = 0;
		for (int i = pos[1] - 1; i; -- i)
		{
			++ now;
			if(s[i] == '*')
			{
				++ totl;
				timesl = now;
			}
		}
		int timesr = 0, totr = 0;
		now = 0;
		for (int i = pos[1] + 1; i <= n; ++ i)
		{
			++ now;
			if(s[i] == '*')
			{
				++ totr;
				timesr = now;
			}
		}
		printf("%d\n", max(totl, totr));
		if(totl < totr)
		printf("%d\n", timesr);
		else
		if(totl > totr)
		printf("%d\n", timesl);
		else
		printf("%d\n", min(timesl, timesr));
	}
	else
	{
		printf("%d\n", sf[n]);
		int l = 1, r = n;
		while(l < r)
		{
			int mid = (l + r) >> 1;
			if(check(mid))r = mid;
			else l = mid + 1;
		}
		printf("%d\n", l);
	}
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int n;
char s[1000010];
int sf[1000010];
int pos[1000010];
int dp[1000010];
int tot = 0;
int check(int o)
{
	memset(dp, 0, sizeof(dp));
	for (int i = 1; i <= tot; ++ i)
	{
		if(sf[pos[i] - o - 1] - sf[pos[i - 1]] <= 0)
		dp[i] = max(dp[i], pos[i]);
		if(sf[pos[i] - 1] - sf[pos[i - 1]] <= 0)
		dp[i] = max(dp[i], pos[i] + o);
		if(i > 1 && sf[pos[i] - o - 1] - sf[dp[i - 2]] <= 0)
		dp[i] = max(dp[i], pos[i - 1] + o);
	}
	return (sf[n] - sf[dp[tot]] <= 0);
}
int main()
{
	scanf("%d", &n);
	scanf("%s", s + 1);
	for (int i = 1; i <= n; ++ i)
	{
		sf[i] = sf[i - 1];
		if(s[i] == 'P')
		{
			pos[++ tot] = i;
		}
		if(s[i] == '*')
		{
			++ sf[i];
		}
	}
	for (int i = n + 1; i <= 1e6; ++ i)
	sf[i] = sf[i - 1];
	if(tot == 1)
	{
		int now = 0;
		int timesl = 0, totl = 0;
		for (int i = pos[1] - 1; i; -- i)
		{
			++ now;
			if(s[i] == '*')
			{
				++ totl;
				timesl = now;
			}
		}
		int timesr = 0, totr = 0;
		now = 0;
		for (int i = pos[1] + 1; i <= n; ++ i)
		{
			++ now;
			if(s[i] == '*')
			{
				++ totr;
				timesr = now;
			}
		}
		printf("%d\n", min(totl, totr));
		if(totl < totr)
		printf("%d\n", timesr);
		else
		if(totl > totr)
		printf("%d\n", timesl);
		else
		printf("%d\n", min(timesl, timesr));
	}
	else
	{
		printf("%d\n", sf[n]);
		int l = 1, r = n;
		while(l < r)
		{
			int mid = (l + r) >> 1;
			if(check(mid))r = mid;
			else l = mid + 1;
		}
		printf("%d\n", l);
	}
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int n;
char s[2000010];
int sf[2000010];
int pos[2000010];
int dp[2000010];
int tot = 0;
int check(int o)
{
	memset(dp, 0, sizeof(dp));
	for (int i = 1; i <= tot; ++ i)
	{
		if(sf[pos[i] - o - 1] - sf[dp[i - 1]] <= 0)
		dp[i] = max(dp[i], pos[i]);
		if(sf[pos[i] - 1] - sf[dp[i - 1]] <= 0)
		dp[i] = max(dp[i], pos[i] + o);
		if(i > 1 && sf[pos[i] - o - 1] - sf[dp[i - 2]] <= 0)
		dp[i] = max(dp[i], pos[i - 1] + o);
	}
	return (sf[n] - sf[dp[tot]] <= 0);
}
int main()
{
	scanf("%d", &n);
	scanf("%s", s + 1);
	for (int i = 1; i <= n; ++ i)
	{
		sf[i] = sf[i - 1];
		if(s[i] == 'P')
		{
			pos[++ tot] = i;
		}
		if(s[i] == '*')
		{
			++ sf[i];
		}
	}
	for (int i = n + 1; i <= 2e6; ++ i)
	sf[i] = sf[i - 1];
	if(tot == 1)
	{
		int now = 0;
		int timesl = 0, totl = 0;
		for (int i = pos[1] - 1; i; -- i)
		{
			++ now;
			if(s[i] == '*')
			{
				++ totl;
				timesl = now;
			}
		}
		int timesr = 0, totr = 0;
		now = 0;
		for (int i = pos[1] + 1; i <= n; ++ i)
		{
			++ now;
			if(s[i] == '*')
			{
				++ totr;
				timesr = now;
			}
		}
		printf("%d\n", max(totl, totr));
		if(totl < totr)
		printf("%d\n", timesr);
		else
		if(totl > totr)
		printf("%d\n", timesl);
		else
		printf("%d\n", min(timesl, timesr));
	}
	else
	{
		printf("%d\n", sf[n]);
		int l = 1, r = n;
		while(l < r)
		{
			int mid = (l + r) >> 1;
			if(check(mid))r = mid;
			else l = mid + 1;
		}
		printf("%d\n", l);
	}
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int n;
char s[1000010];
int sf[1000010];
int pos[1000010];
int dp[1000010];
int tot = 0;
int check(int o)
{
	memset(dp, 0, sizeof(dp));
	for (int i = 1; i <= tot; ++ i)
	{
		if(sf[pos[i] - o - 1] - sf[dp[i - 1]] <= 0)
		dp[i] = max(dp[i], pos[i]);
		if(sf[pos[i] - 1] - sf[dp[i - 1]] <= 0)
		dp[i] = max(dp[i], pos[i] + o);
		if(i > 1 && sf[pos[i] - o - 1] - sf[dp[i - 2]] <= 0)
		dp[i] = max(dp[i], pos[i - 1] + o);
	}
	return (sf[n] - sf[dp[tot]] <= 0);
}
int main()
{
	scanf("%d", &n);
	scanf("%s", s + 1);
	for (int i = 1; i <= n; ++ i)
	{
		sf[i] = sf[i - 1];
		if(s[i] == 'P')
		{
			pos[++ tot] = i;
		}
		if(s[i] == '*')
		{
			++ sf[i];
		}
	}
	for (int i = n + 1; i <= 1e6; ++ i)
	sf[i] = sf[i - 1];
	if(tot == 1)
	{
		int now = 0;
		int timesl = 0, totl = 0;
		for (int i = pos[1] - 1; i; -- i)
		{
			++ now;
			if(s[i] == '*')
			{
				++ totl;
				timesl = now;
			}
		}
		int timesr = 0, totr = 0;
		now = 0;
		for (int i = pos[1] + 1; i <= n; ++ i)
		{
			++ now;
			if(s[i] == '*')
			{
				++ totr;
				timesr = now;
			}
		}
		printf("%d\n", max(totl, totr));
		if(totl < totr)
		printf("%d\n", timesr);
		else
		if(totl > totr)
		printf("%d\n", timesl);
		else
		printf("%d\n", min(timesl, timesr));
	}
	else
	{
		printf("%d\n", sf[n]);
		int l = 1, r = n;
		while(l < r)
		{
			int mid = (l + r) >> 1;
			if(check(mid))r = mid;
			else l = mid + 1;
		}
		printf("%d\n", l);
	}
}


#include <bits/stdc++.h>
const int MAXN = 1e6+5;
using namespace std;
int n,a[MAXN*2],num,d[MAXN*2],b[MAXN*2];
int p[MAXN*2];
string s;
bool check(int k)
{
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==1)
		{
			if(cnt>=i)
			{
				continue;
			}
			if(d[i+k]==d[i])
				return 0;
			if(d[i+k]-d[i]==1)
			{
				i=p[d[i+k]];
				continue;
			}
			if(d[i+k]-d[i]>=2)
			{
				cnt=p[d[i+k]-1]+k;
				continue;
			}
		}
		if(a[i]==2)
			cnt=i+k;
	}
	return 1;
}
int main()
{
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='.')
			a[i+1]=0;
		else if(s[i]=='*')
			a[i+1]=1;
		else
		{
			a[i+1]=2;
			num++;
		}
	}
	for(int i=1;i<=2*n;i++)
	{
		if(a[i]==2)
		{
			d[i]=d[i-1]+1;
			p[d[i]]=i;
		}
		else
			d[i]=d[i-1];
	}
	for(int i=1;i<=2*n;i++)
	{
		if(a[i]==1)
			b[i]=b[i-1]+1;
		else
			b[i]=b[i-1];
	}
	if(num==1)
	{
		int f=0,num1=0,num2=0,t1=n,t2=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]==2)
				f=i;
			else if(a[i]==1)
			{
				if(f==0)
				{
					num1++;
					t1=min(t1,i);
				}
				else
				{
					num2++;
					t2=max(t2,i);
				}
			}
		}
		if(num1>num2)
			cout<<num1<<" "<<f-t1<<endl;
		else if(num1<num2)
			cout<<num2<<" "<<t2-f<<endl;
		else
			cout<<num1<<" "<<min(f-t1,t2-f)<<endl;
		return 0;
	}
	int l=1,r=n,ans=n;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid))
		{
			r=mid-1;
			ans=mid;
		}
		else
			l=mid+1;
	}
	cout<<b[n]<<" "<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
const int MAXN = 1e6+5;
using namespace std;
int n,a[MAXN],num,d[MAXN],b[MAXN];
int p[MAXN],dp[MAXN];
string s;
bool check(int k)
{
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=d[n];i++)
	{
		if(dp[i-1]>=p[i]-1 || b[dp[i-1]]==b[p[i]-1])
			dp[i]=max(dp[i],p[i]+k);
		if(dp[i-1]>=p[i]-k-1 || b[dp[i-1]]==b[p[i]-k-1])
			dp[i]=max(dp[i],p[i]);
		if(i>1 && (dp[i-2]>=p[i]-k+1 || b[dp[i-2]]==b[p[i]-k-1]))
			dp[i]=max(dp[i],p[i-1]+k);
	}
	if(b[dp[d[n]]]==b[n])
		return 1;
	else
		return 0;
}
int main()
{
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='.')
			a[i+1]=0;
		else if(s[i]=='*')
			a[i+1]=1;
		else
		{
			a[i+1]=2;
			num++;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==2)
		{
			d[i]=d[i-1]+1;
			p[d[i]]=i;
		}
		else
			d[i]=d[i-1];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==1)
			b[i]=b[i-1]+1;
		else
			b[i]=b[i-1];
	}
	if(num==1)
	{
		int f=0,num1=0,num2=0,t1=n,t2=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]==2)
				f=i;
			else if(a[i]==1)
			{
				if(f==0)
				{
					num1++;
					t1=min(t1,i);
				}
				else
				{
					num2++;
					t2=max(t2,i);
				}
			}
		}
		if(num1>num2)
			cout<<num1<<" "<<f-t1<<endl;
		else if(num1<num2)
			cout<<num2<<" "<<t2-f<<endl;
		else
			cout<<num1<<" "<<min(f-t1,t2-f)<<endl;
		return 0;
	}
	int l=1,r=n,ans=n;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid))
		{
			r=mid-1;
			ans=mid;
		}
		else
			l=mid+1;
	}
	cout<<b[n]<<" "<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
const int MAXN = 1e6+5;
using namespace std;
int n,a[MAXN*2],num,d[MAXN*2],b[MAXN*2];
int p[MAXN*2];
string s;
bool check(int k)
{
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==1)
		{
			if(cnt>=i)
			{
				continue;
			}
			if(d[i+k]==d[i])
				return 0;
			if(d[i+k]-d[i]==1)
			{
				i=p[d[i+k]];
				continue;
			}
			if(d[i+k]-d[i]>=2)
			{
				cnt=p[d[i+k]-1]+k;
				continue;
			}
		}
		if(a[i]==2)
			cnt=i+k;
	}
	return 1;
}
int main()
{
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='.')
			a[i+1]=0;
		else if(s[i]=='*')
			a[i+1]=1;
		else
		{
			a[i+1]=2;
			num++;
		}
	}
	if(num==1)
	{
		int f=0,num1=0,num2=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]==2)
				f=i;
			else if(a[i]==1)
			{
				if(f==0)
					num1++;
				else num2++;
			}
		}
		if(num1>num2)
			cout<<num1<<" "<<f-1<<endl;
		else if(num1<num2)
			cout<<num2<<" "<<n-f<<endl;
		else
			cout<<num1<<" "<<min(f-1,n-f)<<endl;
		return 0;
	}
	for(int i=1;i<=2*n;i++)
	{
		if(a[i]==2)
		{
			d[i]=d[i-1]+1;
			p[d[i]]=i;
		}
		else
			d[i]=d[i-1];
	}
	for(int i=1;i<=2*n;i++)
	{
		if(a[i]==1)
			b[i]=b[i-1]+1;
		else
			b[i]=b[i-1];
	}
	int l=1,r=n,ans=n;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid))
		{
			r=mid-1;
			ans=mid;
		}
		else
			l=mid+1;
	}
	cout<<b[n]<<" "<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
const int MAXN = 1e6+5;
using namespace std;
int n,a[MAXN],num,d[MAXN],b[MAXN];
int p[MAXN],dp[MAXN];
string s;
bool check(int k)
{
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=d[n];i++)
	{
		if(dp[i-1]>=p[i]-1 || b[dp[i-1]]==b[p[i]-1])
			dp[i]=max(dp[i],p[i]+k);
		if(dp[i-1]>=p[i]-k-1 || b[dp[i-1]]==b[p[i]-k-1])
			dp[i]=max(dp[i],p[i]);
		if(i>1 && (dp[i-2]>=p[i]-k+1 || b[dp[i-2]]==b[p[i]-k-1]))
			dp[i]=max(dp[i],p[i-1]+k);
		dp[i]=min(dp[i],n);
	}
	if(dp[d[n]]==n)
		return 1;
	else return 0;
}
int main()
{
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='.')
			a[i+1]=0;
		else if(s[i]=='*')
			a[i+1]=1;
		else
		{
			a[i+1]=2;
			num++;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==2)
		{
			d[i]=d[i-1]+1;
			p[d[i]]=i;
		}
		else
			d[i]=d[i-1];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==1)
			b[i]=b[i-1]+1;
		else
			b[i]=b[i-1];
	}
	if(num==1)
	{
		int f=0,num1=0,num2=0,t1=n,t2=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]==2)
				f=i;
			else if(a[i]==1)
			{
				if(f==0)
				{
					num1++;
					t1=min(t1,i);
				}
				else
				{
					num2++;
					t2=max(t2,i);
				}
			}
		}
		if(num1>num2)
			cout<<num1<<" "<<f-t1<<endl;
		else if(num1<num2)
			cout<<num2<<" "<<t2-f<<endl;
		else
			cout<<num1<<" "<<min(f-t1,t2-f)<<endl;
		return 0;
	}
	int l=1,r=n,ans=n;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid))
		{
			r=mid-1;
			ans=mid;
		}
		else
			l=mid+1;
	}
	cout<<b[n]<<" "<<ans<<endl;
	return 0;
}


#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
#define N 1100010
using namespace std;
inline int read()
{
	int neg=1,num=0;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')neg=-1;
	for(;isdigit(c);c=getchar())num=(num<<1)+(num<<3)+c-'0';
	return neg*num;
}
int n,x[N],sum[N],f[N],cnt=0;
char s[N];
inline bool none(int l,int r){return l>r || sum[l-1]==sum[r];}
inline void Update(int &a,int b){if(a<b)a=b;}
inline bool check(int t)
{
	for(int i=0;i<=cnt;i++)f[i]=0;
	for(int i=1;i<=cnt;i++)
	{
		if(none(f[i]+1,x[i]-t-1))Update(f[i+1],x[i]);
		if(none(f[i]+1,x[i]-1))Update(f[i+1],x[i]+t);
		if(i>1 && none(f[i-1]+1,x[i]-t-1))Update(f[i+1],x[i-1]+t);
	}
	return none(f[cnt+1]+1,n);
}
int main()
{
	scanf("%d%s",&n,s+1);
	int pos=-1;
	for(int i=1;i<=n;i++)if(s[i]=='P')pos=x[++cnt]=i;
	if(cnt==1)
	{
		int L=0,R=0,lpos=-1,rpos=-1;
		for(int i=pos-1;i;i--)if(s[i]=='*')L++,lpos=i;
		for(int i=pos+1;i<=n;i++)if(s[i]=='*')R++,rpos=i;
		if(L!=R)printf("%d %d\n",max(L,R),L>R?pos-lpos:rpos-pos);
		else printf("%d %d\n",L,min(pos-lpos,rpos-pos));
		exit(0);
	}
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+(s[i]=='*');
	int l=0,r=n,ans=n;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid))r=mid-1,ans=mid;
		else l=mid+1;
	}
	printf("%d %d\n",sum[n],ans);
	return 0;
}


#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
#define N 1100010
using namespace std;
inline int read()
{
	int neg=1,num=0;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')neg=-1;
	for(;isdigit(c);c=getchar())num=(num<<1)+(num<<3)+c-'0';
	return neg*num;
}
int n,x[N],sum[N],f[N],cnt=0;
char s[N];
inline bool none(int l,int r){return l>r || sum[l-1]==sum[r];}
inline void Update(int &a,int b){if(a<b)a=b;}
inline bool check(int t)
{
	for(int i=0;i<=cnt+1;i++)f[i]=0;
	for(int i=1;i<=cnt;i++)
	{
		if(none(f[i]+1,x[i]-t-1))Update(f[i+1],x[i]);
		if(none(f[i]+1,x[i]-1))Update(f[i+1],x[i]+t);
		if(i>1 && none(f[i-1]+1,x[i]-t-1))Update(f[i+1],x[i-1]+t);
	}
	return none(f[cnt+1]+1,n);
}
int main()
{
	scanf("%d%s",&n,s+1);
	int pos=-1;
	for(int i=1;i<=n;i++)if(s[i]=='P')pos=x[++cnt]=i;
	if(cnt==1)
	{
		int L=0,R=0,lpos=-1,rpos=-1;
		for(int i=pos-1;i;i--)if(s[i]=='*')L++,lpos=i;
		for(int i=pos+1;i<=n;i++)if(s[i]=='*')R++,rpos=i;
		if(L!=R)printf("%d %d\n",max(L,R),L>R?pos-lpos:rpos-pos);
		else printf("%d %d\n",L,min(pos-lpos,rpos-pos));
		exit(0);
	}
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+(s[i]=='*');
	int l=0,r=n,ans=n;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid))r=mid-1,ans=mid;
		else l=mid+1;
	}
	printf("%d %d\n",sum[n],ans);
	return 0;
}


#include <bits/stdc++.h>
#define maxn 1000006

using namespace std;

int N,Dp[maxn],T[maxn],T2[maxn],ult1,ult2,sol,cantX,P,arr[maxn],cont1,cont2,pos,pes,ini,fin;
char S[maxn];

bool cumpl(int d)
{
  int pos1,pos2,pos22;
  bool b=0;
  Dp[0]=1;
  for(int i=1;i<=N;i++){
    if(S[i]=='.')
      Dp[i]=Dp[i-1];
    else
       if(S[i]=='*'){
         pos=lower_bound(arr+1,arr+1+P,i-d)-arr;
         pos2=lower_bound(arr+1,arr+1+P,i)-arr;
         pos2--;
         pos1=pos;
         pos22=arr[pos2-1];
         pos2=arr[pos2];
         pos1=arr[pos1];
         if(!pos1 || pos1>i)
            goto tab;
         if(Dp[pos1-1]){
            Dp[i]=1;
            goto tab;
           }
         if(pos1==pos2)
            goto tab;
         if(pos2-d-1 <=0 ){
            Dp[i]=1;
            goto tab;
           }
         pos1=arr[pos+1];
         Dp[i]=( T[pos22-1]-T[pos1-d-2] != 0);
        }
       else
         if(S[i]=='P'){
            if((i-d-1)<=0)
               Dp[i]=1;
            else
               Dp[i]=(T[i-1]-T[i-d-2]!=0);
         }
     tab:
     T[i]=T[i-1]+Dp[i];
    }

  if(Dp[N])
        b=1;

  for(int i=1;i<=N;i++)
    Dp[i]=T[i]=T2[i]=0;
  return b;
}

int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> N >> (S+1);

    for(int i=1;i<=N;i++){
        if(S[i]=='P')
          pos=i,arr[++P]=i;
        if(S[i]=='*')
          cantX++;
      }

    if(P==1)
    {
       for(int i=pos-1;i>=1;i--)
          if(S[i]=='*')
            cont1++,ult1=i;
       for(int i=pos+1;i<=N;i++)
          if(S[i]=='*')
            cont2++,ult2=i;

       if(cont1>cont2)
          sol=pos-ult1,cantX=cont1;
       else
          if(cont1<cont2)
            sol=ult2-pos,cantX=cont2;
          else
            sol=min(pos-ult1,ult2-pos),cantX=cont1;

      goto fin;
    }

    ini=0,fin=N;
    while(ini<=fin)
    {
     int mid=(ini+fin)/2;
     if(cumpl(mid))
        fin=mid-1,sol=mid;
     else
        ini=mid+1;
    }

    fin:
    cout << cantX << " " <<sol << '\n';

    return 0;
}


#include <bits/stdc++.h>
#define maxn 1000006

using namespace std;

int N,Dp[maxn],T[maxn],T2[maxn],ult1,ult2,sol,cantX,P,arr[maxn],cont1,cont2,pos,pes,ini,fin;
char S[maxn];

bool cumpl(int d)
{
  int pos1,pos2,pos22;
  bool b=0;
  Dp[0]=1;
  for(int i=1;i<=N;i++){
    if(S[i]=='.')
      Dp[i]=Dp[i-1];
    else
       if(S[i]=='*'){
         pos=lower_bound(arr+1,arr+1+P,i-d)-arr;
         pos2=lower_bound(arr+1,arr+1+P,i)-arr;
         pos2--;
         pos1=pos;
         pos22=arr[pos2-1];
         pos2=arr[pos2];
         pos1=arr[pos1];
         if(!pos1 || pos1>i)
            goto tab;
         if(Dp[pos1-1] || Dp[pos2-1]){
            Dp[i]=1;
            goto tab;
           }
         if(pos1==pos2)
            goto tab;
         if(pos2-d-1 <=0 ){
            Dp[i]=1;
            goto tab;
           }
         pos1=arr[pos+1];
         Dp[i]=( T[pos22-1]-T[pos1-d-2] != 0);
        }
       else
         if(S[i]=='P'){
            if((i-d-1)<=0)
               Dp[i]=1;
            else
               Dp[i]=(T[i-1]-T[i-d-2]!=0);
         }
     tab:
     T[i]=T[i-1]+Dp[i];
    }

  if(Dp[N])
        b=1;

  for(int i=1;i<=N;i++)
    Dp[i]=T[i]=T2[i]=0;
  return b;
}

int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> N >> (S+1);

    for(int i=1;i<=N;i++){
        if(S[i]=='P')
          pos=i,arr[++P]=i;
        if(S[i]=='*')
          cantX++;
      }

    if(P==1)
    {
       for(int i=pos-1;i>=1;i--)
          if(S[i]=='*')
            cont1++,ult1=i;
       for(int i=pos+1;i<=N;i++)
          if(S[i]=='*')
            cont2++,ult2=i;

       if(cont1>cont2)
          sol=pos-ult1,cantX=cont1;
       else
          if(cont1<cont2)
            sol=ult2-pos,cantX=cont2;
          else
            sol=min(pos-ult1,ult2-pos),cantX=cont1;

      goto fin;
    }

    ini=0,fin=N;
    while(ini<=fin)
    {
     int mid=(ini+fin)/2;
     if(cumpl(mid))
        fin=mid-1,sol=mid;
     else
        ini=mid+1;
    }

    fin:
    cout << cantX << " " <<sol << '\n';

    return 0;
}