#include <bits/stdc++.h>
const int maxn = 1E+6 + 5;
const int INF = 0x3f3f3f3f;
int n, cnt1, cnt2;
int dp[maxn], sum[maxn];
char s[maxn];
std::vector<int> dog;
inline int ask(int l, int r) { return (l > r) ? 0 : sum[r] - sum[l - 1]; }
bool check(int d) {
  for (int i = 1; i <= cnt1; ++i) {
    dp[i] = 0;
    if (!ask(dp[i - 1] + 1, dog[i] - d - 1))
      dp[i] = std::max(dp[i], std::max(dp[i - 1], dog[i]));
    if (!ask(dp[i - 1] + 1, dog[i] - 1))
      dp[i] = std::max(dp[i], std::max(dp[i - 1], dog[i] + d));
    if (i > 1 && dog[i - 1] >= dog[i] - d &&
        !ask(dp[i - 2] + 1, dog[i] - d - 1))
      dp[i] = std::max(dp[i], dog[i - 1] + d);
  }
  return dp[cnt1] > n || sum[dp[cnt1]] == sum[n];
}
int main() {
  scanf("%d\n%s", &n, s + 1);
  for (int i = 1; i <= n; ++i) {
    if (s[i] == '*') s[i] = 'B';
    if (s[i] == 'P') s[i] = 'D';
  }
  dog.push_back(-INF);
  for (int i = 1; i <= n; ++i) {
    sum[i] = sum[i - 1];
    if (s[i] == 'D') ++cnt1, dog.push_back(i);
    if (s[i] == 'B') ++cnt2, ++sum[i];
  }
  if (!cnt1) return puts("0 0"), 0;
  if (cnt1 == 1) {
    int tmp = 0, first = 0, last;
    for (int i = 1; i <= n; ++i) {
      if (s[i] == 'B') last = i;
      if (s[i] == 'B' && !first) first = i;
    }
    for (int i = 1; i <= n; ++i) {
      if (s[i] == 'D') {
        if (tmp * 2 != cnt2)
          return printf("%d %d", std::max(tmp, cnt2 - tmp),
                        tmp > cnt2 - tmp ? i - first : last - i),
                 0;
        else
          return printf("%d %d", tmp, std::min(i - first, last - i)), 0;
      }
      if (s[i] == 'B') ++tmp;
    }
  }
  int l = 1, r = n, mid;
  while (l < r) {
    mid = l + r >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%d %d", cnt2, l);
}
