s=[i for i in eval(input())];g,p=s.count("g"),s.count("p");print(((g-p)//2))
s=eval(input())

print(((s.count("g")-s.count("p"))//2))
s = [i for i in eval(input())]
g, p = s.count("g"), s.count("p")
print(((g - p) // 2))

s = eval(input())
print(((s.count("g") - s.count("p")) // 2))

-s = [i for i in eval(input())] -g, p = s.count("g"), s.count("p") -print(((g - p) // 2)) +s = eval(input()) +print(((s.count("g") - s.count("p")) // 2))