#include <bits/stdc++.h>
using namespace std;
const int N = 1100000;
char str[N];
int sum[N], nxt[N];
int dp[N], pos[N], posn;
bool can(int mid, int n) {
  posn = 0;
  pos[posn] = 0;
  int rp = 0;
  for (int i = 1; i <= n; i++)
    if (str[i] == '*') rp = i;
  for (int i = 1; i <= n; i++)
    if (str[i] == 'P') pos[++posn] = i;
  for (int i = 0; i <= n; i++) dp[i] = 0;
  for (int i = 1; i <= posn; i++) {
    int r = dp[i - 1], l = pos[i] - mid;
    if (l > r && sum[l - 1] - sum[r]) return false;
    dp[i] = max(pos[i], dp[i - 1]);
    if (!(pos[i] > r && sum[pos[i] - 1] - sum[r])) {
      dp[i] = max(dp[i], pos[i] + mid);
    }
    if (i >= 2) {
      r = dp[i - 2];
      if (!(l > r && sum[l - 1] - sum[r])) {
        dp[i] = max(dp[i], pos[i - 1] + mid);
      }
    }
  }
  return dp[posn] >= rp;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n >> str + 1;
  nxt[n + 1] = n + 1;
  for (int i = n; i >= 1; i--) {
    if (str[i] == '*')
      nxt[i] = i;
    else
      nxt[i] = nxt[i + 1];
  }
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + (str[i] == '*');
  int cnt = 0;
  for (int i = 1; i <= n; i++) cnt += str[i] == 'P';
  if (cnt == 1) {
    int lp = n, rp = 0;
    for (int i = 1; i <= n; i++)
      if (str[i] == '*') rp = i;
    for (int i = n; i >= 1; i--)
      if (str[i] == '*') lp = i;
    for (int i = 1; i <= n; i++)
      if (str[i] == 'P') {
        if (sum[i] > sum[n] - sum[i] ||
            (sum[i] == sum[n] - sum[i] && i - lp < rp - i)) {
          cout << sum[i] << " " << i - lp << "\n";
          return 0;
        } else {
          cout << sum[n] - sum[i] << " " << rp - i << "\n";
          return 0;
        }
        return 0;
      }
    return 0;
  }
  int st = 0, en = n, mid, ans;
  while (st <= en) {
    mid = st + en >> 1;
    if (can(mid, n))
      ans = mid, en = mid - 1;
    else
      st = mid + 1;
  }
  cout << sum[n] << " " << ans << "\n";
  return 0;
}
