#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T, class T1>
inline void gn(T &first, T1 &second) {
  gn(first);
  gn(second);
}
template <class T, class T1, class T2>
inline void gn(T &first, T1 &second, T2 &z) {
  gn(first);
  gn(second);
  gn(z);
}
template <class T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <class T>
inline void printsp(T first) {
  print(first);
  putchar(' ');
}
template <class T>
inline void println(T first) {
  print(first);
  putchar('\n');
}
template <class T, class U>
inline void print(T first, U second) {
  printsp(first);
  println(second);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
char s[2000100];
int cnt[2000100], dp[2000100][2];
vector<int> pos;
int n;
int f(int u, int v) {
  if (u > v) return 0;
  return cnt[min(v, 2 * n)] - cnt[u - 1];
}
int can(int t) {
  for (int i = 0; i <= pos.size(); i++) dp[i][0] = dp[i][1] = 0;
  pos.push_back(n + t + 1);
  int ans = 0, u = 0;
  for (int i = 0; i < pos.size(); i++) {
    while (u < pos.size() && pos[u] < pos[i] - t) u++;
    if (f(pos[i] - t, pos[i]) == cnt[pos[i]]) dp[i][0] = pos[i];
    if (u < i) {
      if (dp[i][0] && i) smax(dp[i][0], pos[i - 1] + t);
      if (u == i - 1) {
        if (dp[u][0]) smax(dp[i][0], max(pos[i], dp[u][0]));
        if (dp[u][1]) smax(dp[i][0], max(pos[i], dp[u][1]));
        if (u) {
          if (dp[u - 1][1] && f(dp[u - 1][1] + 1, pos[i] - t - 1) == 0)
            smax(dp[i][0], max(pos[i], pos[i - 1] + t));
          if (dp[u - 1][0] && f(dp[u - 1][0] + 1, pos[i] - t - 1) == 0)
            smax(dp[i][0], max(pos[i], pos[i - 1] + t));
        }
      } else {
        if (dp[u][0] || dp[u][1]) smax(dp[i][0], max(pos[i], pos[i - 1] + t));
      }
    } else {
      if (i) {
        if (dp[i][0]) smax(dp[i][0], pos[i - 1] + t);
        if (dp[i - 1][0] && f(dp[i - 1][0] + 1, pos[i] - 1 - t) == 0)
          smax(dp[i][0], max(pos[i], dp[i - 1][0]));
        if (dp[i - 1][1] && f(dp[i - 1][1] + 1, pos[i] - 1 - t) == 0)
          smax(dp[i][0], max(pos[i], dp[i - 1][1]));
      }
    }
    if (!cnt[pos[i]]) dp[i][1] = pos[i] + t;
    if (i) {
      int v = max(dp[i - 1][0], dp[i - 1][1]);
      if (f(v + 1, pos[i] - 1) == 0) dp[i][1] = pos[i] + t;
    }
  }
  pos.pop_back();
  return f(1, max(dp[pos.size()][0], dp[pos.size()][1])) == cnt[n];
}
int main() {
  gn(n);
  scanf("%s", s + 1);
  memset(s + n + 1, 0, sizeof(s + n + 1));
  for (int i = 1; i < 2000100; i++) cnt[i] = cnt[i - 1] + (s[i] == '*');
  for (int i = 1; i <= n; i++)
    if (s[i] == 'P') pos.push_back(i);
  if (pos.size() == 1) {
    int u = pos[0];
    int ans = max(f(1, pos[0]), f(pos[0], n));
    if (f(1, pos[0]) > f(pos[0], n)) {
      for (int i = 1; i <= n; i++) {
        if (cnt[i] == 1) {
          print(ans, pos[0] - i);
          break;
        }
      }
    } else if (f(1, pos[0]) < f(pos[0], n)) {
      for (int i = n; i >= 1; i--) {
        if (s[i] == '*') {
          print(ans, i - pos[0]);
          break;
        }
      }
    } else {
      int dis = 0;
      for (int i = 1; i < pos[0]; i++)
        if (s[i] == '*') {
          dis = pos[0] - i;
          break;
        }
      for (int i = n; i > pos[0]; i--)
        if (s[i] == '*') {
          smin(dis, i - pos[0]);
          break;
        }
      print(ans, dis);
    }
    return 0;
  }
  int st = -1, ed = n;
  while (ed - st > 1) {
    int mid = st + ed >> 1;
    if (can(mid))
      ed = mid;
    else
      st = mid;
  }
  print(cnt[n], ed);
  return 0;
}
