S = eval(input())

X = [('g' if i % 2 == 0 else 'p') for i in range(len(S))]



ans = 0

for s, x in zip(S, X):

    if s == 'g' and x == 'p':

        ans += 1



    if s == 'p' and x == 'g':

        ans -= 1



print(ans)

S = eval(input())

N = len(S)

P = S.count('p')



print((N // 2 - P))

S = eval(input())
X = [("g" if i % 2 == 0 else "p") for i in range(len(S))]
ans = 0
for s, x in zip(S, X):
    if s == "g" and x == "p":
        ans += 1
    if s == "p" and x == "g":
        ans -= 1
print(ans)

S = eval(input())
N = len(S)
P = S.count("p")
print((N // 2 - P))

-X = [("g" if i % 2 == 0 else "p") for i in range(len(S))] -ans = 0 -for s, x in zip(S, X): -    if s == "g" and x == "p": -        ans += 1 -    if s == "p" and x == "g": -        ans -= 1 -print(ans) +N = len(S) +P = S.count("p") +print((N // 2 - P))