program test
implicit none
character*100000 :: s
integer :: i,j,k,n,score_a

read(*,*) s

n = LEN_TRIM(s)

score_a = 0

do i=1,n
	if(s(i:i) .eq. "g") then
		score_a = score_a + 1
	endif
enddo

score_a = score_a - (n+1)/2

write(*,*) score_a

end program