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