#include <bits/stdc++.h>
long long gi() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) f ^= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f ? x : -x;
}
std::mt19937 rnd(time(NULL));
template <class T>
void cxk(T& a, T b) {
  a = a > b ? a : b;
}
template <class T>
void cnk(T& a, T b) {
  a = a < b ? a : b;
}
char S[1000010];
int n, nxt[1000010];
std::vector<int> dogs;
int Next(int r) { return r <= n ? nxt[std::max(0, r)] : (int)1e9; }
int f[2][2], g[2][2];
bool check(int mid) {
  f[0][1] = -1e9;
  f[0][0] = Next(0);
  g[0][0] = g[0][1] = 0;
  int t = 0;
  for (int i = 1, p, lp = 0; i <= dogs.size(); ++i) {
    p = dogs[i - 1];
    g[!t][1] = p + mid;
    memset(f[!t], -63, sizeof f[!t]);
    for (int j = 0; j < 2; ++j) {
      if (p - mid > f[t][j]) continue;
      if (p > g[t][j])
        g[!t][0] = p, cxk(f[!t][0], Next(p));
      else if (g[t][j] == lp + mid)
        g[!t][0] = lp + mid, cxk(f[!t][0], Next(g[t][j]));
      cxk(f[!t][1], std::min(Next(p + mid), f[t][j] < p ? f[t][j] : (int)1e9));
    }
    t ^= 1;
    lp = p;
  }
  return std::max(f[t][0], f[t][1]) > n;
}
int main() {
  n = gi();
  int dog = 0, bone = 0;
  scanf("%s", S + 1);
  for (int i = 1; i <= n; ++i) dog += S[i] == 'P', bone += S[i] == '*';
  if (dog == 1) {
    int pos;
    for (int i = 1; i <= n; ++i)
      if (S[i] == 'P') pos = i;
    int cl = 0, tl = 0, cr = 0, tr = 0;
    for (int i = 1; i <= n; ++i)
      if (S[i] == '*')
        if (i < pos) {
          if (!cl) tl = pos - i;
          ++cl;
        } else
          ++cr, tr = i - pos;
    if (cl < cr)
      cl = cr, tl = tr;
    else if (cl == cr)
      cnk(tl, tr);
    printf("%d %d\n", cl, tl);
  } else {
    for (int i = 1; i <= n; ++i)
      if (S[i] == 'P') dogs.push_back(i);
    if (dogs.empty()) return 0;
    dogs.push_back(n + n + 2);
    nxt[n + 1] = 1e9;
    for (int i = n; ~i; --i) nxt[i] = S[i + 1] == '*' ? i + 1 : nxt[i + 1];
    int l = 0, r = n, mid;
    while (l < r) {
      mid = l + r >> 1;
      if (check(mid))
        r = mid;
      else
        l = mid + 1;
    }
    printf("%d %d\n", bone, l);
  }
  return 0;
}
