#include <bits/stdc++.h>
using namespace std;
int n, doge[1000007], bone[1000007], flag[1000007], suf[1000007], bonefirst,
    bonelast;
char s[1000007];
bool check(int x) {
  memset(flag, 0, sizeof(flag));
  flag[0] = 1;
  for (int i = 1; i <= n; ++i) {
    if (flag[i - 1]) {
      if (s[i] == '.') flag[i] = 1;
      if (s[i] == 'P') flag[min(min(suf[i] - 1, n), i + x)] = 1;
      if (s[i] == '*') {
        if (suf[i] - i <= x) {
          flag[suf[i]] = 1;
          if (suf[suf[i]] - i <= x)
            flag[min(min(suf[suf[suf[i]]] - 1, n), suf[i] + x)] = 1;
        }
      }
    }
  }
  return flag[n];
}
int main() {
  scanf("%d%s", &n, s + 1);
  suf[n + 1] = 0x3f3f3f3f;
  for (int i = n; i; --i) {
    if (s[i] == 'P')
      doge[++doge[0]] = i;
    else if (s[i] == '*') {
      bone[++bone[0]] = i;
      if (bone[0] == 1) bonelast = i;
      bonefirst = i;
    }
    suf[i] = (s[i + 1] == 'P' ? i + 1 : suf[i + 1]);
  }
  if (doge[0] == 1) {
    int sum1 = 0, sum2 = 0, t1 = 0, t2 = 0, i = doge[1] + 1, j = doge[1] - 1;
    while (i <= bonelast) sum1 += (s[i++] == '*'), t1++;
    while (j >= bonefirst) sum2 += (s[j--] == '*'), t2++;
    if (sum1 == sum2)
      return printf("%d %d", sum1, min(t1, t2)), 0;
    else if (sum1 < sum2)
      return printf("%d %d", sum2, t2), 0;
    else
      return printf("%d %d", sum1, t1), 0;
  } else {
    int l = 1, r = n;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (check(mid))
        r = mid - 1;
      else
        l = mid + 1;
    }
    printf("%d %d", bone[0], l);
  }
  return 0;
}
