#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int n, p[1000010], sum[1000010], cnt = 0, f[1000010][2], r[1000010];
char s[1000010];
bool chk(int x) {
  f[0][0] = f[0][1] = r[0];
  for (int i = 1; i <= cnt; i++) {
    f[i][1] = max(f[i - 1][0], f[i - 1][1]) >= p[i]
                  ? r[min(n + 1, p[i] + x + 1)]
                  : max(f[i - 1][0], f[i - 1][1]);
    f[i][0] = r[0];
    if (f[i - 1][0] >= p[i] - x)
      f[i][0] = max({f[i][0], f[i - 1][0], r[p[i] + 1]});
    else
      f[i][0] = max(f[i][0], f[i - 1][0]);
    if (f[i - 1][1] >= p[i] - x)
      f[i][0] =
          max(f[i][0], r[min(n + 1, max({0, p[i - 1] + x + 1, p[i] + 1}))]);
    else
      f[i][0] = max(f[i][0], f[i - 1][1]);
  }
  return max(f[cnt][0], f[cnt][1]) == n + 1;
}
int main() {
  scanf("%d%s", &n, s + 1);
  p[0] = -inf;
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1];
    if (s[i] == 'P')
      p[++cnt] = i;
    else if (s[i] == '*')
      sum[i]++;
  }
  r[n + 1] = n + 1;
  for (int i = n; i >= 0; i--)
    if (s[i] == '*')
      r[i] = i;
    else
      r[i] = r[i + 1];
  if (cnt == 1) {
    int l = 1, r = n;
    while (s[l] != '*') l++;
    while (s[r] != '*') r--;
    pair<int, int> ans = max(make_pair(sum[p[1] - 1], l - p[1]),
                             make_pair(sum[n] - sum[p[1]], p[1] - r));
    printf("%d %d\n", ans.first, -ans.second);
    return 0;
  }
  printf("%d ", sum[n]);
  int l = 1, len = n;
  while (len) {
    int md = l + (len >> 1);
    if (!chk(md)) {
      l = md + 1;
      len = len - (len >> 1) - 1;
    } else
      len >>= 1;
  }
  printf("%d\n", l);
}
