#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
long long mul(long long a, long long b) { return (a * b) % (1000000007); }
long long add(long long a, long long b) { return (a + b) % (1000000007); }
long long sub(long long a, long long b) {
  return ((a - b) % (1000000007) + (1000000007)) % (1000000007);
}
void upd(long long &a, long long b) {
  a = (a % (1000000007) + b % (1000000007)) % (1000000007);
}
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, a[(1234567)] = {};
char s[(1234567)];
vector<int> v;
int dp[(1234567)];
bool empty(int l, int r) { return r < l || a[r] - a[l - 1] == 0; }
bool check(int w) {
  memset(dp, 0, sizeof(dp));
  int sz = ((v).size());
  for (int i = 0; i < sz; i++) {
    int pos = v[i], j = i + 1;
    if (empty(dp[i] + 1, v[i] - w - 1)) dp[j] = max(dp[j], v[i]);
    ;
    if (empty(dp[i] + 1, v[i] - 1)) dp[j] = max(dp[j], v[i] + w);
    ;
    if (i >= 1) {
      if (empty(dp[j - 2] + 1, v[i] - w - 1) && v[i] - w < v[i - 1])
        dp[j] = max(dp[j], v[i - 1] + w);
      ;
    }
  }
  if (empty(dp[sz] + 1, n)) {
    return 1;
  }
  return 0;
}
int main() {
  n = read();
  cin >> (s + 1);
  a[0] = 0;
  for (int i = 1; i <= n; i++) a[i] += a[i - 1] + (s[i] == '*');
  for (int i = 1; i <= n; i++)
    if (s[i] == 'P') v.push_back(i);
  if (((v).size()) == 1) {
    int p = v[0];
    int p1 = a[v[0]], c1 = p - 1;
    int p2 = a[n] - a[v[0]], c2 = n - p;
    for (int i = 1; i <= p; i++)
      if (s[i] == '.')
        c1--;
      else
        break;
    for (int i = n; i >= p; i--)
      if (s[i] == '.')
        c2--;
      else
        break;
    if (p1 > p2 || p1 == p2 && c1 < c2) {
      cout << p1 << ' ' << c1 << endl;
    } else
      cout << p2 << ' ' << c2 << endl;
    return 0;
  } else {
    cout << a[n] << ' ';
    int l = 0, r = n, ans = l;
    while (l <= r) {
      int m = r + l >> 1;
      if (check(m))
        ans = m, r = m - 1;
      else
        l = m + 1;
    }
    cout << ans << endl;
  }
  return 0;
}
