#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, s[N], f[N];
char ch[N];
vector<int> p;
inline bool ok(int l, int r) { return l > r ? 1 : (s[r] - s[l - 1] == 0); }
inline int sum(int l, int r) { return l > r ? 0 : s[r] - s[l - 1]; }
inline bool ck(int x) {
  fill(f, f + n + 1, 0);
  for (int i = 1; i <= p.size(); ++i) {
    int pos = p[i - 1];
    if (ok(f[i - 1] + 1, pos - 1)) f[i] = max(f[i], pos + x);
    if (ok(f[i - 1] + 1, pos - x - 1)) f[i] = max(f[i], pos);
    if (i > 1)
      if (ok(f[i - 2] + 1, pos - x - 1))
        f[i] = max(f[i], max(p[i - 2] + x, pos));
  }
  return ok(f[p.size()] + 1, n);
}
int main() {
  scanf("%d", &n);
  scanf("%s", ch + 1);
  for (int i = 1; i <= n; ++i) {
    s[i] = s[i - 1];
    if (ch[i] == 'P')
      p.push_back(i);
    else if (ch[i] == '*')
      ++s[i];
  }
  if (p.size() == 1) {
    int pos = p[p.size() - 1];
    int suml = sum(1, pos - 1), sumr = sum(pos + 1, n);
    if (!suml && !sumr) return puts("0 0"), 0;
    int l = 1;
    while (ok(1, l)) ++l;
    int r = n;
    while (ok(r, n)) --r;
    if (l > pos) return printf("%d %d", sumr, r - pos), 0;
    if (r < pos) return printf("%d %d", suml, pos - l), 0;
    if (suml == sumr)
      printf("%d %d", suml, min(pos - l, r - pos));
    else
      printf("%d %d", max(suml, sumr), suml > sumr ? pos - l : r - pos);
  } else {
    int l = 0, r = n;
    while (l + 1 < r) {
      int mid = l + r >> 1;
      ck(mid) ? r = mid : l = mid;
    }
    printf("%d %d\n", sum(1, n), r);
  }
  return 0;
}
