#include <bits/stdc++.h>
using namespace std;
int n, m;
string s;
int loc[1000050];
int a[1000050];
int sum[1000050];
bool check1(int l, int r) {
  if (l > r) return 1;
  if (sum[r] - sum[l - 1] == 0) return 1;
  return 0;
}
bool check2(int mid) {
  loc[0] = 0;
  bool ok = 1;
  for (int i = 1; i <= m; i++)
    if (!check1(loc[i - 1] + 1, a[i] - mid - 1)) {
      ok = 0;
      break;
    } else if (check1(loc[i - 1] + 1, a[i] - 1))
      loc[i] = a[i] + mid;
    else if (i > 1 && check1(loc[i - 2] + 1, a[i] - mid - 1))
      loc[i] = max(a[i - 1] + mid, a[i]);
    else
      loc[i] = a[i];
  return ok;
}
int main() {
  cin >> n >> s;
  s = 'a' + s;
  for (int i = 1; i <= n; i++)
    if (s[i] == '*')
      sum[i] = sum[i - 1] + 1;
    else
      sum[i] = sum[i - 1];
  for (int i = 1; i <= n; i++)
    if (s[i] == 'P') a[++m] = i;
  if (m == 1) {
    int mine = 1e9, maxe = 0;
    for (int i = 1; i <= n; i++)
      if (s[i] == '*') {
        mine = min(mine, i);
        maxe = max(maxe, i);
      }
    int ch1 = sum[a[1]], ch2 = sum[n] - sum[a[1]];
    if (ch1 > ch2 || (ch1 == ch2 && (a[1] - mine < maxe - a[1])))
      cout << ch1 << ' ' << a[1] - mine << endl;
    else
      cout << ch2 << ' ' << maxe - a[1] << endl;
    return 0;
  }
  int st = 0, nd = n + 1;
  while (st + 1 < nd) {
    int mid = (st + nd) / 2;
    if (check2(mid) && check1(loc[m] + 1, n))
      nd = mid;
    else
      st = mid;
  }
  cout << sum[n] << " " << nd << endl;
}
