#include <bits/stdc++.h>
using namespace std;
int pre[1000005];
int ind[1000005], prevInd[1000005];
char in[1000005];
long long dp[1000005], ad[1000005];
long long getDpSum(int l, int r) {
  assert(l <= r);
  long long f = 0;
  if (r >= 0) {
    f = dp[r];
  }
  if (l - 1 >= 0) {
    f -= dp[l - 1];
  }
  return f;
}
int lastInd[1000005];
bool canCover(int len, int n) {
  for (int i = 0; i < 1000005; ++i) {
    dp[i] = 0;
    ad[i] = 0;
  }
  dp[0] = 1;
  int g = n;
  for (int i = n; i; --i) {
    while (ind[g] - ind[i] > len) {
      --g;
    }
    lastInd[i] = g;
  }
  int lind = 1;
  long long cur = 0;
  for (int i = 1; i <= n; ++i) {
    while (ind[i] - ind[lind] > len) {
      ++lind;
    }
    cur += ad[i];
    dp[i] += dp[i - 1];
    if (in[i] == 'P') {
      if (getDpSum(lind - 1, i - 1) > 0) {
        ++cur;
        ad[i + 1]--;
      }
      if (prevInd[i] != -1) {
        if (lind < prevInd[i] && getDpSum(lind - 1, prevInd[i] - 1) > 0) {
          int ed = max(i + 1, lastInd[prevInd[i]] + 1);
          ++cur;
          --ad[ed];
        }
      }
      if (getDpSum(i - 1, i - 1) > 0) {
        ++cur;
        int ed = lastInd[i] + 1;
        --ad[ed];
      }
    }
    if (cur) {
      ++dp[i];
    }
  }
  return getDpSum(n, n) > 0;
}
char s[1000005];
pair<int, int> get(int l, int r, int ind) {
  int num = 0, t = 0;
  for (int i = l; i <= r; ++i) {
    if (s[i] == '*') {
      ++num;
      t = max(t, abs(ind - i));
    }
  }
  return make_pair(num, -t);
}
void solve() {
  int n;
  scanf("%d %s ", &n, s + 1);
  int numPack = 0;
  for (int i = 1; i <= n; ++i) {
    if (s[i] == 'P') {
      ++numPack;
    }
  }
  if (numPack == 1) {
    int ind;
    for (int i = 1; i <= n; ++i) {
      if (s[i] == 'P') {
        ind = i;
      }
    }
    pair<int, int> x = max(get(1, ind - 1, ind), get(ind + 1, n, ind));
    printf("%d %d\n", x.first, -x.second);
  } else {
    int pos = 0;
    for (int i = 1; i <= n; ++i) {
      if (s[i] != '.') {
        ++pos;
        ind[pos] = i;
        in[pos] = s[i];
      }
    }
    int lastPack = -1;
    for (int i = 1; i <= pos; ++i) {
      if (in[i] == 'P') {
        prevInd[i] = lastPack;
        lastPack = i;
      }
    }
    for (int i = 1; i <= n; ++i) {
      pre[i] = pre[i - 1];
      if (s[i] == '*') {
        ++pre[i];
      }
    }
    int numAs = pre[n];
    int l = 1, r = n, mid;
    while (l < r) {
      mid = (l + r) / 2;
      if (canCover(mid, pos)) {
        r = mid;
      } else {
        l = mid + 1;
      }
    }
    printf("%d %d\n", numAs, l);
  }
}
int main() {
  solve();
  return 0;
}
