#include #include using namespace std; int main() { string s; cin >> s; int res = 0; int pain = s.find("pain"); if (pain != -1) { for (int i = 0; i < pain; i++) { if (s[i] == 'p' && s[i + 1] == 'o' && s[i + 2] == 'n') { res++; } } if (res > 1) cout << res - 1 << endl; else cout << -1 << endl; } else cout << -1 << endl; }