#include <bits/stdc++.h>
using std::max;
using std::min;
const int N = 1000005;
int a[N], pre[N], cnt, n, ans, tot, dp[N];
char s[N];
void solve() {
  int t1 = 1, t2 = n;
  for (; s[t1] != '*'; t1++)
    ;
  for (; s[t2] != '*'; t2--)
    ;
  if (pre[a[1]] > tot - pre[a[1]] ||
      (pre[a[1]] == tot - pre[a[1]] && a[1] - t1 < t2 - a[1]))
    printf("%d %d\n", pre[a[1]], a[1] - t1);
  else
    printf("%d %d\n", tot - pre[a[1]], t2 - a[1]);
  exit(0);
}
int sum(int l, int r) {
  if (r < l) return 0;
  l = max(l, 1), r = min(r, n);
  return pre[r] - pre[l - 1];
}
bool chk(int dis) {
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= cnt; i++) {
    if (!sum(dp[i - 1] + 1, a[i])) dp[i] = max(dp[i], a[i] + dis);
    if (!sum(dp[i - 1] + 1, a[i] - dis - 1)) dp[i] = max(dp[i], a[i]);
    if (i >= 2 && !sum(dp[i - 2] + 1, a[i] - dis - 1))
      dp[i] = max(dp[i], a[i - 1] + dis);
  }
  if (dp[cnt] > n) return 1;
  return pre[dp[cnt]] >= tot;
}
int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'P') a[++cnt] = i;
    if (s[i] == '*') pre[i] = 1, tot++;
  }
  for (int i = 1; i <= n; i++) pre[i] += pre[i - 1];
  if (cnt == 1) solve();
  printf("%d ", pre[n]);
  int l = 1, r = n, ans = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (chk(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%d\n", ans);
}
