#include <bits/stdc++.h>
using namespace std;
int n;
char s[1011111];
int pig[1011111], npig;
int food[1011111], nfood;
int cnt[1011111];
int dp[1011111];
void upd(int &a, int b) { a = max(a, b); }
bool chk(int d) {
  dp[0] = dp[1] = dp[2] = 0;
  for (int i = 0; i < npig; i++) {
    dp[i + 3] = 0;
    int it = dp[i];
    if (it >= nfood) return true;
    if (food[it] < pig[i] - d) return false;
    if (food[it] < pig[i]) {
      upd(dp[i + 1], upper_bound(food, food + nfood, pig[i]) - food);
      if (i < npig - 1 && food[it] >= pig[i + 1] - d)
        upd(dp[i + 2], upper_bound(food, food + nfood, pig[i] + d) - food);
    } else
      upd(dp[i + 1], upper_bound(food, food + nfood, pig[i] + d) - food);
  }
  return dp[npig] >= nfood;
}
pair<int, int> calc() {
  if (npig == 1) {
    int x = cnt[pig[0]];
    if (x < nfood - x)
      return make_pair(nfood - x, food[nfood - 1] - pig[0]);
    else if (x > nfood - x)
      return make_pair(x, pig[0] - food[0]);
    else
      return make_pair(x, min(pig[0] - food[0], food[nfood - 1] - pig[0]));
  }
  pig[npig] = -1;
  int l = 0, r = n, ans = -1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (chk(mid)) {
      ans = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  return make_pair(nfood, ans);
}
int main() {
  scanf("%d%s", &n, s);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'P') pig[npig++] = i;
    if (s[i] == '*') {
      food[nfood++] = i;
      cnt[i] = 1;
    }
    if (i) cnt[i] += cnt[i - 1];
  }
  pair<int, int> p = calc();
  printf("%d %d\n", p.first, p.second);
  return 0;
}
