#include using namespace std; string s; int n = -1; bool f; int main() { cin >> s; for (int i = 0; i < s.size(); i++) { if (s.substr(i, 3) == "pon") { n++; i += 2; } else if (s.substr(i, 4) == "pain") { f = 1; break; } } if (f && n > 0) cout << n << endl; else cout << -1 << endl; }