#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
int N, P[MAXN], rsum[MAXN], f[MAXN], cnt, ans;
char ch;
bool sec_empty(int l, int r) { return l > r || rsum[r] == rsum[l - 1]; }
bool check(int t) {
  for (int i = 1; i <= cnt; ++i) f[i] = 0;
  for (int i = 1; i <= cnt; ++i) {
    f[i] = P[i];
    if (!sec_empty(f[i - 1] + 1, P[i] - t - 1)) return false;
    if (sec_empty(f[i - 1] + 1, P[i] - 1))
      f[i] = P[i] + t;
    else if (i >= 2 && sec_empty(f[i - 2] + 1, P[i] - t - 1))
      f[i] = max(f[i], P[i - 1] + t);
  }
  return sec_empty(f[cnt] + 1, N);
}
void binary() {
  int l = 1, r = N, mid;
  while (l < r) {
    mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  ans = l;
  return;
}
void Input() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    ch = getchar();
    if (ch == '\n') ch = getchar();
    rsum[i] = rsum[i - 1];
    if (ch == '*') ++rsum[i];
    if (ch == 'P') P[++cnt] = i;
  }
  return;
}
int main() {
  Input();
  if (cnt == 1) {
    int v1 = rsum[P[1]], v2 = rsum[N] - rsum[P[1]];
    int lb = upper_bound(rsum, rsum + N, 0) - rsum;
    int rb = lower_bound(rsum, rsum + N, rsum[N]) - rsum;
    if (v1 == v2) printf("%d %d\n", v1, min(P[1] - lb, rb - P[1]));
    if (v1 > v2) printf("%d %d\n", v1, P[1] - lb);
    if (v1 < v2) printf("%d %d\n", v2, rb - P[1]);
    return 0;
  }
  binary();
  printf("%d %d\n", rsum[N], ans);
  return 0;
}
