#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, sgn = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') sgn = -1;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
  return x * sgn;
}
const int N = 1e6 + 10;
int p[N], s[N], n, cnt, f[N];
char S[N];
bool isept(int l, int r) { return l > r || (s[r] - s[l - 1] <= 0); }
bool check(int mid) {
  f[0] = 0;
  for (int i = 1; i <= cnt; i++) {
    if (!isept(f[i - 1] + 1, p[i] - mid - 1)) return 0;
    f[i] = p[i];
    if (isept(f[i - 1] + 1, p[i]))
      f[i] = p[i] + mid;
    else if (i >= 2 && isept(f[i - 2] + 1, p[i] - mid - 1))
      f[i] = max(p[i - 1] + mid, f[i]);
  }
  return isept(f[cnt] + 1, n);
}
int main() {
  n = read();
  scanf("%s", S + 1);
  for (int i = 1; i <= n; i++) {
    s[i] = s[i - 1] + (S[i] == '*');
    if (S[i] == 'P') p[++cnt] = i;
  }
  if (cnt == 1) {
    int a = s[p[1]], b = s[n] - s[p[1]];
    int lp = lower_bound(s + 1, s + p[1] + 1, 1) - s,
        rp = lower_bound(s + p[1], s + n + 1, s[n]) - s;
    if (a == b)
      printf("%d %d\n", a, min(p[1] - lp, rp - p[1]));
    else if (a < b)
      printf("%d %d\n", b, rp - p[1]);
    else
      printf("%d %d\n", a, p[1] - lp);
    return 0;
  }
  int l = 0, r = n;
  while (l <= r) {
    int mid = l + r >> 1;
    if (check(mid))
      r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%d %d\n", s[n], l);
  return 0;
}
