#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { string s; cin >> s; int cnt = -1; bool has = false; rep(i, s.size()) { if (s.substr(i, 4) == "pain") { has = true; break; } if (s.substr(i, 3) == "pon") ++cnt; } cout << (cnt > 0 && has ? cnt : -1) << endl; return 0; }