#include <bits/stdc++.h>   using namespace std;   char s[200010];   int n;   bool query(int x) {     int t = -1, l = -1;     for (int i = 0; i < n; i++) {       l--;       if (s[i] ==  . ) continue;       if (s[i] ==  P ) {         if (t == -1) t = i;         int tmp = max(x - (i - t) * 2, (x - (i - t)) / 2);         l = max(tmp, l);         if (i - t > x) return 0;         t = -1;       }       if (s[i] ==  * ) {         if (l >= 0) continue;         if (t == -1) t = i;       }     }     if (t != -1) return 0;     return 1;   }   int bs(int l, int r) {     if (l == r) return l;     int m = (l + r) / 2;     if (query(m))       return bs(l, m);     else       return bs(m + 1, r);   }   int main() {     cin >> n;     scanf( %s , s);     cout << bs(0, n * 2) <<   n ;     return 0;   }   