#include <bits/stdc++.h>
int n, tot;
char s[1000010];
int sum[1000010], dp[1000010], dogs[1000010];
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;
}
