#include #include #include #include #include #include #include #include #include #include using ll = long long; using namespace std; int main() { string s, p1 = "pon", p2 = "pain"; ll cnt = 0, t; bool pain = false; cin >> s; int len = s.size(); for (int i = 0; i < len; i++){ if (s[i] == 'p'){ if (s.substr(i, 3) == p1) cnt++; if (s.substr(i, 4) == p2){ pain = true; break; } } } if (pain && cnt >= 2) cout << cnt - 1 << endl; else cout << -1 << endl; }