#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
int stars, pac, n, nxtPac[maxn], x, pre[maxn];
char s[maxn];
bool f[maxn];
inline void solve1() {
  int a = 0, b = 0, c = 0, d = 0;
  for (int i = x - 1; i >= 1; --i)
    if (s[i] == '*') ++a, b = x - i;
  for (int i = x + 1; i <= n; ++i)
    if (s[i] == '*') ++c, d = i - x;
  if (a > c)
    cout << a << " " << b;
  else if (c > a)
    cout << c << " " << d;
  else if (b < d)
    cout << a << " " << b;
  else
    cout << c << " " << d;
}
bool dfs(int x, int m) {
  if (x > n) return true;
  if (f[x]) return false;
  f[x] = true;
  if (s[x] == '.')
    return dfs(x + 1, m);
  else if (s[x] == '*') {
    int nx = nxtPac[x], ny = nxtPac[nx + 1];
    if (nx != n + 1 && x + m >= nx && dfs(nx + 1, m)) return true;
    if (nx != n + 1 && ny != n + 1 && x + m >= ny &&
        dfs(min(nx + m + 1, nxtPac[ny + 1]), m))
      return true;
  } else
    return dfs(min(x + m + 1, nxtPac[x + 1]), m);
  return false;
}
inline bool check(int m) {
  memset(f, 0, sizeof f);
  return dfs(1, m);
}
inline void solve2() {
  int l = 0, r = maxn, res = maxn;
  while (l <= r) {
    int m = (l + r) >> 1;
    if (check(m)) {
      res = m;
      r = m - 1;
    } else
      l = m + 1;
  }
  cout << stars << " " << res;
}
int main() {
  scanf("%d%s", &n, s + 1);
  nxtPac[n + 1] = n + 1;
  for (int i = n; i >= 1; --i) {
    if (s[i] == '*')
      ++stars;
    else if (s[i] == 'P')
      ++pac, x = i;
    nxtPac[i] = (s[i] == 'P') ? i : nxtPac[i + 1];
  }
  for (int i = 1; i <= n; ++i) pre[i] = pre[i - 1] + (s[i] == '*');
  if (pac == 1)
    solve1();
  else
    solve2();
  return 0;
}
