#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 69;
int n, f[maxn], p[maxn], sum[maxn], k;
string s;
int get(int l, int r) {
  if (l > r) return 0;
  return sum[r] - sum[l - 1];
}
bool kt(int t) {
  for (int i = 1; i <= k; i++) {
    if (get(f[i - 1] + 1, p[i] - t - 1)) return 0;
    if (get(f[i - 1] + 1, p[i] - 1) == 0)
      f[i] = p[i] + t;
    else if (i > 1 && get(f[i - 2] + 1, p[i] - t - 1) == 0)
      f[i] = max(p[i - 1] + t, p[i]);
    else
      f[i] = p[i];
  }
  return get(f[k] + 1, n) == 0;
}
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> s;
  s = ' ' + s;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'P') p[++k] = i;
    sum[i] = sum[i - 1] + (s[i] == '*');
  }
  if (k == 1) {
    int cntl = 0, cntr = 0, l = 0, r = 0;
    for (int i = p[k] - 1; i >= 1; i--) {
      if (s[i] == '*') cntl++, l = i;
    }
    for (int i = p[k] + 1; i <= n; i++) {
      if (s[i] == '*') cntr++, r = i;
    }
    if (cntl > cntr)
      cout << cntl << ' ' << p[k] - l;
    else if (cntl < cntr)
      cout << cntr << ' ' << r - p[k];
    else
      cout << cntl << ' ' << min(p[k] - l, r - p[k]);
  } else {
    int l = 1, r = n;
    while (l < r) {
      int m = (l + r) / 2;
      if (kt(m))
        r = m;
      else
        l = m + 1;
    }
    cout << sum[n] << ' ' << l;
  }
  return 0;
}
