#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000010;
int _w;
int bmax(int &a, int b) { return a = b > a ? b : a; }
int n;
char s[MAXN];
namespace NoStarOrPackman {
bool check() {
  int cs = 0, cp = 0;
  for (int i = 1; i <= n; ++i) {
    cs += s[i] == '*';
    cp += s[i] == 'P';
  }
  return !cs || !cp;
}
void solve() { puts("0 0"); }
}  // namespace NoStarOrPackman
namespace OnePackman {
bool check() {
  int cp = 0;
  for (int i = 1; i <= n; ++i) cp += s[i] == 'P';
  return cp == 1;
}
int findp() {
  for (int i = 1; i <= n; ++i)
    if (s[i] == 'P') return i;
  return 0;
}
void solve() {
  int ls = 0, rs = 0, pp = findp(), mxs = 0, mns = n + 1;
  for (int i = 1; i <= n; ++i)
    if (s[i] == '*') {
      ls += i < pp;
      rs += i > pp;
      mxs = max(mxs, i);
      mns = min(mns, i);
    }
  if (ls > rs) {
    printf("%d %d\n", ls, pp - mns);
  } else if (rs > ls) {
    printf("%d %d\n", rs, mxs - pp);
  } else {
    printf("%d %d\n", ls, min(pp - mns, mxs - pp));
  }
}
}  // namespace OnePackman
namespace Solve {
vector<int> P;
int ss[MAXN], f[MAXN], m;
void init() {
  P.push_back(0);
  for (int i = 1; i <= n; ++i) {
    ss[i] = ss[i - 1];
    if (s[i] == '*')
      ++ss[i];
    else if (s[i] == 'P')
      P.push_back(i);
  }
  m = (int)P.size() - 1;
}
bool empty(int l, int r) {
  bool rtn = l > r || !(ss[r] - ss[l - 1]);
  return rtn;
}
bool check(int d) {
  memset(f, 0, sizeof f);
  for (int i = 0; i < m; ++i) {
    int p = P[i + 1];
    if (empty(f[i] + 1, p - 1)) bmax(f[i + 1], p + d);
    if (empty(f[i] + 1, p - d - 1)) bmax(f[i + 1], p);
    if (i && empty(f[i - 1] + 1, p - d - 1)) bmax(f[i + 1], P[i] + d);
    if (!f[i + 1]) return false;
  }
  return empty(f[m] + 1, n);
}
void solve() {
  init();
  int low = 0, high = n;
  while (low < high) {
    int mid = (low + high) / 2;
    if (check(mid))
      high = mid;
    else
      low = mid + 1;
  }
  printf("%d %d\n", ss[n], low);
}
}  // namespace Solve
int main() {
  _w = scanf("%d%s", &n, s + 1);
  if (NoStarOrPackman::check())
    NoStarOrPackman::solve();
  else if (OnePackman::check())
    OnePackman::solve();
  else
    Solve::solve();
  return 0;
}
