let list_of_str s = let rec f i = if i >= String.length s then [] else s.[i] :: f (i+1) in f 0
let f v c = if c = 'g' then v+1 else v-1
let () =
  let r = Scanf.scanf "%s" list_of_str |> List.fold_left f 0 in
  Printf.printf "%d\n" (r/2)