#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
template <class T>
T gcd(T a, T b) {
  return a ? gcd(b % a, a) : b;
}
template <class T>
T sqr(T a) {
  return a * a;
}
template <class T>
T sgn(T a) {
  return a > 0 ? 1 : (a < 0 ? -1 : 0);
}
int n;
int m;
const int N = 1e6 + 10;
char s[N];
int p[N], l[N], r[N], f[N][5];
void upd(int& res, int val, int cur = 0) { res = min(res, max(val, cur)); }
int get(int i, int j) {
  if (i > j) swap(i, j);
  if (j == m) {
    return i == m ? 0 : l[n - 1] - p[i];
  }
  int pos = (p[i] + p[j]) / 2;
  int t1 = max(l[pos] - p[i], p[j] - r[pos + 1]), t2 = 0;
  if (pos > 0) {
    t2 = max(l[pos - 1] - p[i], p[j] - r[pos]);
  }
  int res = max(0, min(t1, t2));
  return res;
}
int getr(int i, int j) {
  int res = max(0, l[max(0, p[j])] - p[i]);
  return res;
}
int getl(int i, int j) {
  int res = max(0, p[j] - r[max(0, p[i])]);
  return res;
}
int go(int i, int state) {
  if (f[i][state - 1] != -1) return f[i][state - 1];
  int res = n;
  switch (state) {
    case 1:
      if (i == m)
        upd(res, getr(i - 1, m));
      else {
        upd(res, go(i + 1, 4));
        upd(res, go(i + 1, 3), get(i - 1, i));
        upd(res, go(i + 1, 1), getr(i - 1, i));
        if (i < m - 1) upd(res, go(i + 2, 4), get(i - 1, i + 1));
      }
      break;
    case 2:
      if (i == m)
        res = getl(i - 2, i - 1) > 0 ? n : getr(i - 1, m);
      else {
        upd(res, go(i + 1, 4), getl(i - 2, i));
        if (getl(i - 2, i - 1) == 0) {
          upd(res, go(i + 1, 1), getr(i - 1, i));
          upd(res, go(i + 1, 3), get(i - 1, i));
          if (i < m - 1) upd(res, go(i + 2, 4), get(i - 1, i + 1));
        }
      }
      break;
    case 3:
      if (i == m)
        res = getr(i - 1, m) > 0 ? n : 0;
      else {
        upd(res, go(i + 1, 2));
        upd(res, go(i + 1, 3), getl(i - 1, i));
      }
      break;
    case 4:
      if (i == m)
        res = getr(i - 2, m);
      else {
        upd(res, go(i + 1, 3), get(i - 2, i));
        upd(res, go(i + 1, 1), getr(i - 2, i));
        if (i < m - 1) upd(res, go(i + 2, 4), get(i - 2, i + 1));
      }
      break;
  }
  return f[i][state - 1] = res;
}
int main() {
  scanf("%d ", &n);
  gets(s);
  int pos = -1;
  int ast = 0;
  for (int i = 0; i <= n; i++) {
    if (s[i] == '*') pos = i, ast++;
    l[i] = pos;
  }
  pos = n;
  for (int i = n; i >= 0; i--) {
    if (s[i] == '*') pos = i;
    r[i] = pos;
  }
  p[m++] = -1;
  p[m++] = -1;
  for (int i = 0; i < n; i++)
    if (s[i] == 'P') p[m++] = i;
  p[m] = n;
  if (m == 3) {
    int pos[2] = {p[2], p[2]}, cnt[2] = {0, 0};
    for (int i = 0; i < n; i++) {
      if (s[i] == '*')
        cnt[i >= p[2]]++,
            pos[i >= p[2]] = i < p[2] ? min(pos[i >= p[2]], i) : i;
    }
    if (cnt[0] == cnt[1]) {
      cout << cnt[0] << " " << min(p[2] - pos[0], pos[1] - p[2]) << endl;
    } else if (cnt[0] > cnt[1]) {
      cout << cnt[0] << " " << p[2] - pos[0] << endl;
    } else if (cnt[1] > cnt[0]) {
      cout << cnt[1] << " " << pos[1] - p[2] << endl;
    }
    return 0;
  }
  memset(f, -1, sizeof(f));
  cout << ast << " " << go(2, 3) << endl;
  return 0;
}
