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