結果
| 問題 | 
                            No.1534 おなかがいたい
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-04-13 17:30:35 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 355 bytes | 
| コンパイル時間 | 241 ms | 
| コンパイル使用メモリ | 82,340 KB | 
| 実行使用メモリ | 65,748 KB | 
| 最終ジャッジ日時 | 2024-10-03 00:18:14 | 
| 合計ジャッジ時間 | 4,614 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 5 TLE * 1 -- * 13 | 
ソースコード
def main():
    s=input()
    if s.find("pain")==-1:
        print(-1)
        exit()
    cnt=0
    while True:
        if s[0:3]=="pon":
            s=s[3:]
            cnt+=1
        else:
            s=s[1:]
        if s[0:4]=="pain":
            break
    result = -1 if cnt<2 else cnt-1
    print(result)
    
if __name__ == "__main__":
    main()