#include <bits/stdc++.h>
inline void in(int &MAGNUS) { scanf("%d", &MAGNUS); }
inline void out(int MAGNUS) { printf("%d\n", MAGNUS); }
inline void in(int &MAGNUS, int &CLAR) { scanf("%d%d", &MAGNUS, &CLAR); }
inline void out(int MAGNUS, int CLAR) { printf("%d %d\n", MAGNUS, CLAR); }
inline void inl(long long &LIV) { scanf("%lld", &LIV); }
inline void inl(long long &LIV, long long &MART) {
  scanf("%lld%lld", &LIV, &MART);
}
inline void outl(long long LIV) { printf("%lld\n", LIV); }
inline void outl(long long LIV, long long MART) {
  printf("%lld %lld\n", LIV, MART);
}
using namespace std;
char s[1000005];
int lastPosition[1000005], dp[1000005], N;
vector<int> packmanPosition;
bool ok(int x) {
  int P = packmanPosition.size();
  dp[0] = lastPosition[0];
  for (int i = 1; i <= P; i++) {
    int currentPackmanPosition = packmanPosition[i - 1];
    if (currentPackmanPosition - x - 1 > dp[i - 1]) return 0;
    if (dp[i - 1] >= currentPackmanPosition)
      dp[i] = lastPosition[min(N, currentPackmanPosition + x)];
    else {
      dp[i] = lastPosition[currentPackmanPosition];
      if (i - 2 >= 0 && currentPackmanPosition - x - 1 <= dp[i - 2]) {
        dp[i] = max(dp[i], lastPosition[min(N, packmanPosition[i - 2] + x)]);
      }
    }
  }
  if (dp[P] == N) return 1;
  return 0;
}
int main() {
  in(N);
  scanf("%s", s + 1);
  for (int i = 1; i <= N; i++)
    if (s[i] == 'P') packmanPosition.push_back(i);
  if (packmanPosition.size() == 1) {
    int starsOnRight = 0, starsOnLeft = 0;
    int lastStarOnRight = packmanPosition[0],
        lastStarOnLeft = packmanPosition[0];
    for (int i = packmanPosition[0] + 1; i <= N; i++) {
      if (s[i] != '*') continue;
      starsOnRight++;
      lastStarOnRight = i;
    }
    for (int i = packmanPosition[0] - 1; i >= 1; i--) {
      if (s[i] != '*') continue;
      starsOnLeft++;
      lastStarOnLeft = i;
    }
    int bestStars = 0, timeNeeded = 1 << 30;
    if (starsOnLeft > starsOnRight) {
      bestStars = starsOnLeft;
      timeNeeded = packmanPosition[0] - lastStarOnLeft;
    } else if (starsOnRight > starsOnLeft) {
      bestStars = starsOnRight;
      timeNeeded = lastStarOnRight - packmanPosition[0];
    } else {
      bestStars = starsOnLeft;
      timeNeeded = min(packmanPosition[0] - lastStarOnLeft,
                       lastStarOnRight - packmanPosition[0]);
    }
    out(bestStars, timeNeeded);
  } else {
    int stars = 0;
    lastPosition[N] = N;
    for (int i = N; i >= 1; i--) {
      if (s[i] != '*')
        lastPosition[i - 1] = lastPosition[i];
      else {
        stars++;
        lastPosition[i - 1] = i - 1;
      }
    }
    int lo = 1, hi = N, ans;
    while (lo <= hi) {
      int mid = (lo + hi) / 2;
      if (ok(mid)) {
        ans = mid;
        hi = mid - 1;
      } else
        lo = mid + 1;
    }
    out(stars, ans);
  }
  return 0;
}
