object Main extends App {
  // val strAry = io.StdIn.readLine().split(' ')
  // println(strAry.sorted.mkString(" "))
  var count = 0
  val number = io.StdIn.readLine().split("").map(_.toInt)
  for(i <- 0 to 3) if(number(i)==2) count += 1
  println(count)

}
