#define _GLIBCXX_DEBUG #define ll long long #include using namespace std; int main() { string S; cin >> S; int s = S.find("pain"); if(s != -1){ string T = S.substr(0, s); int ans = 0; for(int i = 0; i < (int)T.size()-2; i++){ string U = ""; U += T[i]; U += T[i+1]; U += T[i+2]; if(U == "pon") ans++; } if(ans < 2) ans = 0; cout << ans-1 << endl; }else{ cout << s << endl; } }