def d_AtCoDeer_and_RockPaper(S):

    # 解説どおり

    n = len(S)  # ターン数

    p = 0  # 相手がパーを出した回数

    for c in S:

        if c == 'p':

            p += 1

    return n // 2 - p



S = input().strip()

print((d_AtCoDeer_and_RockPaper(S)))
def d_atcodeer_and_rock_paper(S):

    return len(S) // 2 - S.count('p')



S = input().strip()

print((d_atcodeer_and_rock_paper(S)))
def d_AtCoDeer_and_RockPaper(S):
    # 解説どおり
    n = len(S)  # ターン数
    p = 0  # 相手がパーを出した回数
    for c in S:
        if c == "p":
            p += 1
    return n // 2 - p


S = input().strip()
print((d_AtCoDeer_and_RockPaper(S)))

def d_atcodeer_and_rock_paper(S):
    return len(S) // 2 - S.count("p")


S = input().strip()
print((d_atcodeer_and_rock_paper(S)))

-def d_AtCoDeer_and_RockPaper(S): -    # 解説どおり -    n = len(S)  # ターン数 -    p = 0  # 相手がパーを出した回数 -    for c in S: -        if c == "p": -            p += 1 -    return n // 2 - p +def d_atcodeer_and_rock_paper(S): +    return len(S) // 2 - S.count("p") -print((d_AtCoDeer_and_RockPaper(S))) +print((d_atcodeer_and_rock_paper(S)))