#include <bits/stdc++.h>
using namespace std;
const int N = 1000100;
char grass[N];
int len, n, rg, lg, p, sum[N], vis[N], peo[N];
void init() {
  scanf("%d", &n);
  scanf("%s", grass);
  len = n;
}
bool check(int time) {
  memset(vis, 0, sizeof vis);
  if (sum[peo[0]] > 0) {
    if (peo[0] - time - 1 >= 0 && sum[peo[0] - time - 1] > 0) return false;
    vis[0] = peo[0];
    if (peo[1] - time <= 0 || sum[peo[1] - time - 1] <= 0)
      vis[1] = max(vis[1], peo[0] + time);
  } else
    vis[0] = peo[0] + time;
  if (vis[0] >= rg) return true;
  for (int i = 1; i < p; i++) {
    if (vis[i] > n) return true;
    if (sum[peo[i]] - sum[vis[i - 1]] > 0) {
      if (peo[i] - time - 1 >= 0 &&
          sum[peo[i] - time - 1] - sum[vis[i - 1]] > 0)
        return false;
      vis[i] = max(vis[i], peo[i]);
      if (i + 1 != p && (peo[i + 1] - time <= 0 ||
                         sum[peo[i + 1] - time - 1] - sum[vis[i - 1]] <= 0))
        vis[i + 1] = max(vis[i + 1], peo[i] + time);
    } else
      vis[i] = max(vis[i], peo[i] + time);
    if (vis[i] >= rg) return true;
  }
  return vis[p - 1] >= rg;
}
void solve() {
  int pos = 0;
  p = sum[0] = 0;
  rg = -1, lg = -1;
  for (int i = 0; i < len; i++) {
    if (grass[i] == 'P') {
      if (!p) pos = i;
      peo[p++] = i;
    }
    if (grass[i] == '*') {
      if (lg == -1) lg = i;
      rg = i;
      sum[i]++;
    }
    if (i) sum[i] += sum[i - 1];
  }
  n = len - 1;
  if ((rg == -1) || (!p)) {
    printf("0 0\n");
    return;
  }
  if (p == 1) {
    if (sum[pos] >= sum[n] - sum[pos]) {
      if (sum[pos] == sum[n] - sum[pos])
        printf("%d %d\n", sum[pos], min(pos - lg, rg - pos));
      else
        printf("%d %d\n", sum[pos], pos - lg);
    } else
      printf("%d %d\n", sum[n] - sum[pos], rg - pos);
    return;
  }
  int l = 0, r = len + 5;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%d %d\n", sum[n], r);
}
int main() {
  init();
  solve();
  return 0;
}
