s = eval(input())

score = 0

for i in range(len(s)):

    if i % 2 == 0:

        if s[i] == 'p': score -= 1

    else:

        if s[i] == 'g': score += 1

print(score)
s = eval(input())

p = 0

for i in range(len(s)):

    if s[i] == 'p': p += 1

print((-p + len(s) // 2))
s = eval(input())
score = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "p":
            score -= 1
    else:
        if s[i] == "g":
            score += 1
print(score)

s = eval(input())
p = 0
for i in range(len(s)):
    if s[i] == "p":
        p += 1
print((-p + len(s) // 2))

-score = 0 +p = 0 -    if i % 2 == 0: -        if s[i] == "p": -            score -= 1 -    else: -        if s[i] == "g": -            score += 1 -print(score) +    if s[i] == "p": +        p += 1 +print((-p + len(s) // 2))