#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
vector<int> P, A;
int N;
string S;
int sum[MAXN], dp[MAXN];
int isempty(int x, int y) {
  x = max(x, 0);
  return (x > y) ? 1 : !(sum[y] - sum[x]);
}
bool check(int t) {
  for (int i = (0); i < (N + 1); i++) dp[i] = -1;
  for (int i = (0); i < (P.size()); i++) {
    if (isempty(dp[i] + 1, P[i] - t)) dp[i + 1] = max(dp[i + 1], P[i]);
    if (isempty(dp[i] + 1, P[i])) dp[i + 1] = max(dp[i + 1], P[i] + t);
    if (i and isempty(dp[i - 1] + 1, P[i] - t))
      dp[i + 1] = max(dp[i + 1], P[i - 1] + t);
  }
  return dp[P.size()] >= A.back();
}
int main() {
  cin >> N;
  cin >> S;
  sum[0] = 0;
  for (int i = (0); i < (N); i++) {
    sum[i + 1] = sum[i];
    if (S[i] == 'P') P.push_back(i);
    if (S[i] == '*') A.push_back(i), sum[i + 1]++;
  }
  if (P.size() == 1) {
    int eat, tim;
    if (sum[P[0]] > sum[N] - sum[P[0]]) {
      eat = sum[P[0]];
      tim = max(P[0] - A[0], 0);
    } else {
      eat = sum[N] - sum[P[0]];
      tim = max(A.back() - P[0], 0);
    }
    cout << eat << ' ' << tim << endl;
    return 0;
  }
  int l = 0, r = N;
  while (l < r) {
    int mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  cout << A.size() << ' ' << l << endl;
  return 0;
}
