#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long int llINF = (long long)(1e18) + 100;
const int MAXN = 1e6 + 10;
int n, sum[MAXN];
vector<int> pos;
int getsum(int l, int r) {
  if (l > r) return 0;
  if (l <= 0) return sum[r];
  return sum[min(r, n - 1)] - sum[l - 1];
}
int memo[MAXN];
bool check(int val) {
  int m = pos.size();
  memo[0] = 0;
  for (int i = 0; i < m; i++) {
    if (getsum(memo[i], pos[i] - val - 1)) return false;
    if (getsum(memo[i], pos[i])) {
      memo[i + 1] = pos[i] + 1;
      if (i > 0 and getsum(memo[i - 1], pos[i] - val - 1) == 0)
        memo[i + 1] = max(memo[i + 1], pos[i - 1] + val + 1);
    } else
      memo[i + 1] = pos[i] + val + 1;
  }
  return getsum(memo[m], n) == 0;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < n; i++) {
    sum[i] = s[i] == '*';
    if (i > 0) sum[i] += sum[i - 1];
    if (s[i] == 'P') pos.push_back(i);
  }
  if (pos.size() == 1) {
    int cnt, tme;
    cnt = tme = 0;
    for (int i = pos[0]; i < n; i++) {
      if (s[i] == '*') {
        cnt++;
        tme = i - pos[0];
      }
    }
    int aux = 0;
    for (int i = pos[0]; i >= 0; i--) {
      if (s[i] == '*') {
        aux++;
        if (aux == cnt) tme = min(tme, pos[0] - i);
        if (aux > cnt) {
          cnt = aux;
          tme = pos[0] - i;
        }
      }
    }
    cout << cnt << ' ' << tme << '\n';
    return 0;
  }
  int l = 1, r = n, best = -1, meio;
  while (l <= r) {
    meio = (l + r) / 2;
    if (check(meio)) {
      best = meio;
      r = meio - 1;
    } else
      l = meio + 1;
  }
  cout << sum[n - 1] << ' ' << best << '\n';
}
