let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let a = if n mod 10 = 2 then 1 else 0 in
  let b = if (n mod 100) / 10 = 2 then 1 else 0 in
  let c = if (n mod 1000) / 100 = 2 then 1 else 0 in
  let d = if n / 1000 = 2 then 1 else 0 in
  Printf.printf "%d\n" (a+b+c+d)