#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; int main() { string S; cin >> S; int pos = S.find("pain"); if (pos == -1) cout << -1 << endl; else { int cnt = 0; for (int i = 0; i <= pos - 3; i++) { if (S.substr(i, 3) == "pon") cnt++; } if (cnt < 2) cout << -1 << endl; else cout << cnt - 1 << endl; } return 0; }