#include <bits/stdc++.h>
using namespace std;
void Debug() { cout << '\n'; }
template <class FIRST, class... REST>
void Debug(FIRST arg, REST... rest) {
  cout << arg << " ";
  Debug(rest...);
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  if (!v.empty()) {
    for (int i = int(0); i < int((int)(v).size() - 1); i++) out << v[i] << ", ";
    out << v.back();
  }
  out << "]";
  return out;
}
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& v) {
  out << "(" << v.first << ", " << v.second << ")";
  return out;
}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const long long mod = 1000000007;
const int inf = 1 << 29;
const long long linf = 1LL << 60;
const double PI = 3.14159265358979323846;
int N, M;
string str;
int minv, maxv;
int P[1000010];
int S[1000010];
int dp[1000010];
bool exist(int l, int r) { return ((r > l) && (S[r] - S[l])); }
bool C(int m) {
  for (int i = int(0); i < int(M + 1); i++) dp[i] = 0;
  for (int i = int(1); i < int(M + 1); i++) {
    int e = P[i - 1] + 1;
    if (!exist(dp[i - 1], e - m - 1)) dp[i] = max(dp[i], e);
    if (!exist(dp[i - 1], e)) dp[i] = max(dp[i], e + m);
    if (i != 1) {
      int f = P[i - 2] + 1;
      if (!exist(dp[i - 2], e - m - 1)) dp[i] = max(dp[i], f + m);
    }
  }
  return dp[M] > maxv;
}
void solve() {
  cin >> N >> str;
  M = 0;
  for (int i = int(0); i < int(N); i++) {
    if (str[i] == 'P') P[M++] = i;
    S[i + 1] = S[i] + (str[i] == '*');
  }
  minv = inf;
  maxv = -inf;
  for (int i = int(0); i < int(N); i++) {
    if (str[i] != '*') continue;
    minv = min(minv, i);
    maxv = max(maxv, i);
  }
  if (M == 1) {
    int p = P[0];
    int lc = S[p], rc = S[N] - S[p];
    if (lc > rc) {
      cout << lc << " " << p - minv << "\n";
    } else if (lc < rc) {
      cout << rc << " " << maxv - p << "\n";
    } else {
      cout << lc << " " << min(maxv - p, p - minv) << "\n";
    }
    return;
  }
  C(2);
  int lv = 0, rv = N;
  while (rv - lv > 1) {
    int m = (lv + rv) / 2;
    if (C(m))
      rv = m;
    else
      lv = m;
  }
  cout << S[N] << " " << rv << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed;
  cout.precision(20);
  solve();
  return 0;
}
