#include <bits/stdc++.h>
using namespace std;
namespace Acc {
const int N = 1e6 + 9;
char o[N];
int s[N], f[N], p[N], m, n, z;
int ept(int l, int r) { return l > r || s[r] - s[l - 1] == 0; }
int chk(int l) {
  memset(f, 0, n + 1 << 2);
  for (int i = 1; i <= n; ++i) {
    f[i] = p[i];
    if (!ept(f[i - 1] + 1, p[i] - l - 1)) return 0;
    if (ept(f[i - 1] + 1, p[i]))
      f[i] = p[i] + l;
    else if (i > 1 && ept(f[i - 2] + 1, p[i] - l - 1))
      f[i] = max(f[i], p[i - 1] + l);
  }
  return ept(f[n] + 1, m);
}
void work() {
  cin >> m >> o + 1;
  int i, l = 0, r = m + 1, md, r1 = m, r2 = 0;
  for (z = m, i = 1; i <= m; ++i)
    if (s[i] = s[i - 1] + (o[i] == '*'), o[i] == 'P') p[++n] = i;
  if (n == 1) {
    for (i = m; i; --i)
      if (o[i] == '*') r1 = min(r1, i), r2 = max(r2, i);
    if (s[m] - s[p[1]] > s[p[1]] || s[m] - s[p[1]] == s[p[1]])
      cout << s[m] - s[p[1]] << ' ' << r2 - p[1] << '\n';
    else
      cout << s[p[1]] << ' ' << p[1] - r1 << '\n';
    exit(0);
  }
  while (l <= r) {
    if (md = l + r >> 1, chk(md))
      r = md - 1;
    else
      l = md + 1;
  }
  cout << s[m] << ' ' << r + 1 << '\n';
}
}  // namespace Acc
int main() { return Acc::work(), 0; }
