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