import scala.io.StdIn

object Main {

  def main(args: Array[String]): Unit = {

    val n: Int = StdIn.readLine().toInt
    println(solve(n))

  }

  def solve(n: Int): Int = {

    if (n == 0) {
      0
    } else if (n % 10 == 2) {
      solve(n / 10) + 1
    } else {
      solve(n / 10)
    }

  }

}
