import Control.Applicative

solve [] = 0
solve ((i,c):s)
  | odd  i && c == 'g' = 0  + solve s
  | odd  i && c == 'p' = -1 + solve s
  | even i && c == 'g' =  1 + solve s
  | even i && c == 'p' =  0 + solve s
  | otherwise = undefined

main = do
  s <- getLine :: IO String
  print $ solve $ zip [1..] s
