#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = (int)1e6 + 10;
int n;
char str[N];
vector<int> stars;
vector<int> ps;
bool has_stars[N];
void solve_one() {
  int cnt_left = 0, cnt_right = 0;
  int pos_left = ps[0], pos_right = ps[0];
  for (int x : stars) {
    if (x < ps[0]) {
      cnt_left++;
      pos_left = min(pos_left, x);
    } else {
      cnt_right++;
      pos_right = max(pos_right, x);
    }
  }
  auto v1 = make_pair(cnt_left, -(ps[0] - pos_left));
  auto v2 = make_pair(cnt_right, -(pos_right - ps[0]));
  auto result = max(v1, v2);
  printf("%d %d\n", result.first, -result.second);
}
int near_star[N];
int dp[N];
bool check(int len) {
  fill(dp, dp + n + 1, -1);
  for (int i = 0; i < (int)ps.size(); i++) {
    dp[i] = min(dp[i], n);
    int star = (dp[i] == -1 ? stars[0] : near_star[dp[i]]);
    if (star > ps[i])
      dp[i + 1] = max(dp[i + 1], ps[i] + len);
    else {
      if (ps[i] - star > len) continue;
      dp[i + 1] = max(dp[i + 1], ps[i]);
      if (i < (int)ps.size() - 1 && ps[i + 1] - star <= len)
        dp[i + 2] = max(dp[i + 2], ps[i] + len);
    }
  }
  if (dp[(int)ps.size()] >= n || near_star[dp[(int)ps.size()]] == n)
    return true;
  return false;
}
void solve_many() {
  int l = 0, r = n;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  printf("%d %d\n", (int)stars.size(), r);
}
void solve() {
  scanf("%d", &n);
  scanf(" %s", str);
  for (int i = 0; i < n; i++) {
    if (str[i] == 'P')
      ps.push_back(i);
    else if (str[i] == '*')
      stars.push_back(i);
  }
  int last_star = n;
  near_star[n] = n;
  for (int i = n - 1; i >= 0; i--) {
    near_star[i] = last_star;
    if (str[i] == '*') last_star = i;
  }
  for (int i = 0; i < (int)ps.size() - 1; i++) {
    auto it = lower_bound(stars.begin(), stars.end(), ps[i]);
    if (it != stars.end() && *it < ps[i + 1]) has_stars[i] = true;
  }
  if (ps.size() == 1)
    solve_one();
  else
    solve_many();
}
int main() {
  solve();
  (void)0;
  return 0;
}
