#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
char s[maxn];
int n;
int ne[maxn];
int sum[maxn], dp[maxn];
int gs[maxn], sums[maxn];
int fr[maxn];
bool judge(int x) {
  sum[0] = 1;
  dp[0] = 1;
  int bg = 0;
  gs[0] = 0;
  for (int i = 1; i <= n; i++) {
    gs[i] = 0;
    if (s[i - 1] == '.') {
      dp[i] = dp[i - 1];
    } else if (s[i - 1] == 'P') {
      if (i - x - 1 <= 0 || sum[i - 1] - sum[i - x - 2] > 0) {
        dp[i] = 1;
      } else
        dp[i] = 0;
      int d = max(1, i - x);
      if (d <= bg) {
        if (d - 1 <= 0 || sum[bg - 1] - sum[d - 2] > 0) {
          gs[bg] = 1;
          for (int j = bg; j < i; j++) {
            sums[j] = sums[j - 1] + gs[j];
          }
        }
      }
      if (dp[i - 1] == 1) gs[i] = 1;
      bg = i;
    } else {
      int be = max(1, i - x);
      if (sums[i - 1] - sums[be - 1] > 0)
        dp[i] = 1;
      else
        dp[i] = 0;
    }
    sum[i] = sum[i - 1] + dp[i];
    sums[i] = sums[i - 1] + gs[i];
  }
  if (dp[n] == 1) return true;
  return false;
}
int main() {
  int kase = 1;
  while (~scanf("%d", &n)) {
    scanf("%s", s);
    int sg = 0, pl;
    int be = -1;
    ne[n + 1] = n + 1;
    int ans = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (s[i] == 'P') {
        sg++, pl = i;
        ne[i + 1] = i + 1;
      } else
        ne[i + 1] = ne[i + 2];
      if (s[i] == '*') ans++;
    }
    if (sg == 1) {
      int tim = 0, minn = 1e9, cun = 0;
      for (int i = pl; i >= 0; i--) {
        if (s[i] == '*') {
          cun++;
          tim = pl - i;
        }
      }
      int cun2 = 0;
      minn = tim;
      tim = 0;
      for (int i = pl; i < n; i++) {
        if (s[i] == '*') {
          cun2++;
          tim = i - pl;
        }
      }
      if (cun > cun2 || (cun == cun2 && minn < tim)) {
        cout << cun << " " << minn << endl;
      } else
        cout << cun2 << " " << tim << endl;
      continue;
    }
    int l = 0, r = 1e6 + 10;
    while (r - l > 1) {
      int mid = (l + r) / 2;
      if (judge(mid))
        r = mid;
      else
        l = mid;
    }
    printf("%d %d\n", ans, r);
  }
  return 0;
}
