local s = io.read()
local p = 0
local score = 0
for i=1,#s do
  local oh = s:sub(i,i) -- opponent hand
  if p == 0 then -- use 'g'
    score = score + (oh == 'g' and 0 or -1)
    p = 1
  else -- use 'p'
    score = score + (oh == 'g' and 1 or 0)
    p = 0
  end
end
print(score)