#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int possib();
int getl(int);
int getr(int);
int geti(int);
int getf(int);
int dp(int);
int dar[1000006], lar[1000006], rar[1000006], iar[1000006], far[1000006], n, k;
char s[1000006];
int main() {
  scanf("%d", &n);
  scanf("%s", s);
  int paccnt, pacind, eatcnt;
  paccnt = 0;
  pacind = 0;
  eatcnt = 0;
  for (int i = (0); i < (n); ++i) {
    if (s[i] == 'P') {
      paccnt++;
      pacind = i;
    } else if (s[i] == '*') {
      eatcnt++;
    }
  }
  if (paccnt == 1) {
    int lcnt, lt, rcnt, rt;
    lcnt = 0;
    rcnt = 0;
    for (int i = (0); i < (n); ++i) {
      if (pacind - i >= 0 && s[pacind - i] == '*') {
        lcnt++;
        lt = i;
      }
      if (pacind + i < n && s[pacind + i] == '*') {
        rcnt++;
        rt = i;
      }
    }
    auto x = max(make_pair(lcnt, -lt), make_pair(rcnt, -rt));
    printf("%d %d\n", x.first, -x.second);
    return 0;
  }
  for (int i = (0); i < (n); ++i) {
    if (s[i] == 'P')
      lar[i] = i;
    else
      lar[i] = getl(i - 1);
  }
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'P')
      rar[i] = i;
    else
      rar[i] = getr(i + 1);
    if (s[i] == 'P' || s[i] == '*')
      iar[i] = i;
    else
      iar[i] = geti(i + 1);
  }
  int st, en, mid;
  st = 1;
  en = n - 1;
  while (st < en) {
    mid = (st + en) / 2;
    ;
    k = mid;
    if (possib())
      en = mid;
    else
      st = mid + 1;
  }
  printf("%d %d\n", eatcnt, st);
  return 0;
}
int possib() {
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'P') {
      if (getl(i + k) == i)
        far[i] = i + k;
      else
        far[i] = getf(getl(i + k));
    }
  }
  for (int i = (0); i < (n); ++i) dar[i] = -1;
  return dp(geti(0));
}
int getl(int x) {
  if (x < 0) return -1;
  if (x >= n) x = n - 1;
  return lar[x];
}
int getr(int x) {
  if (x >= n) return -1;
  if (x < 0) x = 0;
  return rar[x];
}
int geti(int x) {
  if (x >= n) return -1;
  if (x < 0) x = 0;
  return iar[x];
}
int getf(int x) {
  if (x < 0 || x >= n || s[x] != 'P') {
    printf("ERROR!! %d\n", x);
    return -1;
  }
  return far[x];
}
int dp(int x) {
  ;
  if (x < 0 || x >= n) {
    ;
    return 1;
  }
  if (dar[x] == -1) {
    int i;
    i = getr(x);
    ;
    if (i == -1 || x + k < i) {
      ;
      dar[x] = 0;
      return dar[x];
    }
    if (i == x) {
      ;
      dar[x] = dp(geti(getf(i) + 1));
      return dar[x];
    } else {
      if (dp(geti(i + 1))) {
        ;
        dar[x] = 1;
        return dar[x];
      }
      int j = getr(i + 1);
      if (j == -1 || x + k < j) {
        ;
        dar[x] = 0;
        return dar[x];
      }
      if (j == getl(i + k)) {
        ;
        dar[x] = dp(geti(i + k + 1));
        return dar[x];
      } else {
        ;
        dar[x] = dp(geti(getf(i) + 1));
        return dar[x];
      }
    }
  }
  return dar[x];
}
