#include <bits/stdc++.h>
using namespace std;
string st;
int LAST, FIRST;
int i, p[3020000], t[1020000], l, lf, rt, f[1020000], s, Mn = 1e9, mid;
bool check(int x) {
  f[0] = FIRST - 1;
  for (i = 1; i <= s; ++i) {
    f[i] = t[i];
    if (f[i - 1] > t[i] || (p[t[i]] - p[f[i - 1]] < 1 && i > 1) ||
        (i == 1 && p[t[1]] < 1))
      f[i] = t[i] + x;
    if (t[i] > x && p[t[i] - x - 1] - p[f[i - 1]] > 0) return 0;
    if (i > 1 && p[f[i - 2]] >= p[t[i] - x - 1]) f[i] = max(f[i], t[i - 1] + x);
  }
  if (f[s] >= LAST) return 1;
  return 0;
}
int main() {
  cin >> l;
  LAST = l;
  FIRST = 1E9;
  cin >> st;
  st = " " + st;
  for (i = 1; i <= l; ++i) {
    if (st[i] == 'P') t[++s] = i;
    p[i] = p[i - 1];
    if (st[i] == '*') p[i]++, LAST = i, FIRST = min(FIRST, i);
  }
  for (i = l + 1; i <= l * 3 + 1; ++i) p[i] = p[i - 1];
  if (s == 1) {
    if (p[l] == 0) {
      cout << "0 0";
    } else {
      if ((p[t[1]] > p[LAST] - p[t[1]]) ||
          (p[t[1]] == p[LAST] - p[t[1]] && t[1] - FIRST < LAST - t[1]))
        cout << p[t[1]] << " " << t[1] - FIRST;
      else
        cout << p[LAST] - p[t[1]] << " " << LAST - t[1];
    }
  } else {
    cout << p[l];
    lf = 0;
    rt = l;
    while (lf <= rt) {
      mid = (lf + rt) >> 1;
      if (check(mid))
        Mn = min(mid, Mn), rt = mid - 1;
      else
        lf = mid + 1;
    }
    cout << " " << Mn;
  }
}
