#include int count(char T[]) { int i, j, k = 0, l, flag; char S[501]; for (i = 0; T[i] != 0; i++) S[i] = T[i]; S[i] = 0; do { for (i = 0, flag = 0; S[i] != 0; i++) { if (flag == 0) { if (S[i] == 'p') { flag = 1; l = i; } } else if (flag == 1) { if (S[i] == 'p') l = i; else if (S[i] == 'o') flag = 2; } else { if (S[i] == 'p') { flag = 1; l = i; } else if (S[i] == 'n') { for (i++, j = l; S[i] != 0; i++, j++) S[j] = S[i]; S[j] = 0; i = 0; k++; break; } } } if (S[i] != 0) continue; else break; } while (1); return k; } void chmax(int* a, int b) { if (*a < b) *a = b; } int main() { int N; char S[501]; scanf("%d", &N); scanf("%s", S); int i, j, k, ans = -1; char c; for (i = 3; i < N - 2; i++) { c = S[i]; S[i] = 0; j = count(S); S[i] = c; k = count(&(S[i])); if (j >= 1 && k >= 1) chmax(&ans, j + k - 2); } printf("%d\n", ans); fflush(stdout); return 0; }