import io.StdIn.readLine


object Main {
  def main(args: Array[String]): Unit = {
    val s = readLine()
    var ans = 0
    val win = s.zip(1 to s.length).map { case (c, i) =>
      if (i % 2 == 1) {
        if (c == 'p') ans = ans - 1
      } else {
        if (c == 'g') ans = ans + 1
      }
    }
    println(ans)
  }
}
