#include #define rep(i, n) for (int i = 0; i < n; ++i) typedef long long ll; using namespace std; int main() { string S; cin >> S; bool flag = false; int cnt = 0; rep(i, S.size()) { if (S.compare(i, 3, "pon") == 0) cnt++; else if (S.compare(i, 4, "pain") == 0) { flag = true; break; } } if (flag) { if (cnt < 2) cout << -1; else cout << cnt - 1; } else { cout << -1; } cout << endl; return 0; }