/* -*- coding: utf-8 -*- * * 1534.cc: No.1534 おなかがいたい - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ /* global variables */ char s[MAX_N + 4]; /* subroutines */ /* main */ int main() { scanf("%s", s); int n = strlen(s); char *ept = strstr(s, "pain"); if (ept == nullptr) { puts("-1"); return 0; } int cnt = 0; for (char *cpt = s;;) { cpt = strstr(cpt, "pon"); if (cpt == nullptr || cpt > ept) break; cnt++; cpt++; } printf("%d\n", (cnt < 2) ? -1 : cnt - 1); return 0; }