#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int n, s1, s2;
char s[N];
int f[N], g[N], nx[N], q[5];
void solve() {
  int ans0 = 0, d0 = 0;
  int ans1 = 0, d1 = 0;
  int p = 1;
  for (; s[p] != 'P'; ++p)
    ;
  for (int i = (int)(p); i >= (int)(1); i--)
    if (s[i] == '*') ++ans0, d0 = p - i;
  for (int i = (int)(p); i <= (int)(n); i++)
    if (s[i] == '*') ++ans1, d1 = i - p;
  if (ans0 < ans1) swap(ans0, ans1), swap(d0, d1);
  if (ans0 == ans1 && d0 > d1) swap(d0, d1);
  printf("%d %d\n", ans0, d0);
}
bool check(int v) {
  memset(f, 0, sizeof(f));
  memset(g, 0, sizeof(g));
  f[0] = 1;
  for (int i = (int)(1); i <= (int)(n); i++) {
    g[i] += g[i - 1];
    f[i] |= (g[i] != 0);
    if (s[i] == '.') {
      f[i] |= f[i - 1];
      continue;
    }
    if (s[i] == 'P') {
      if (f[i - 1]) {
        g[i]++;
        g[min(n, i + v) + 1]--;
        f[i] = 1;
      }
      continue;
    }
    if (f[i] || !f[i - 1]) continue;
    int ed = min(n, i + v), cnt = 0;
    for (int j = nx[i]; j <= ed && cnt < 2; j = nx[j]) q[++cnt] = j;
    if (!cnt) return 0;
    if (cnt >= 1) f[q[1]] = 1;
    if (cnt >= 2) {
      g[q[2]]++;
      g[min(q[1] + v, n) + 1]--;
    }
  }
  return f[n];
}
int main() {
  scanf("%d%s", &n, s + 1);
  for (int i = (int)(1); i <= (int)(n); i++) {
    s1 += (s[i] == 'P');
    s2 += (s[i] == '*');
  }
  if (s1 == 1) return solve(), 0;
  int l = 1, r = n, ans = nx[n + 1] = n + 1;
  for (int i = (int)(n); i >= (int)(1); i--)
    nx[i] = (s[i + 1] == 'P' ? i + 1 : nx[i + 1]);
  while (l <= r) {
    int mid = (l + r) / 2;
    if (check(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%d %d\n", s2, ans);
}
