본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬]15881번 Pen Pineapple Apple Pen

by 현장 2021. 7. 28.

-코드

l = int(input())
s = input()
r, i = 0, 0
while i < l - 3:
    if s[i] == 'p' and s[i + 1] == 'P' and s[i + 2] == 'A' and s[i + 3] == 'p':
        r += 1
        i += 4
    else:
        i += 1
print(r)