let ans s =
  let n = String.length s in
  let rec count i ret =
    if i = n then ret
    else if s.[i] = 'p' then count (i+1) (ret+1)
    else count (i+1) ret in
  let p = count 0 0
  in n/2 - p;;

Scanf.scanf "%s" (fun s -> print_int (ans s))
