let explode s =
    let rec exp i l =
        if i < 0 then l else exp (i - 1) (s.[i] :: l) in
    exp (String.length s - 1) []


let count2 l =
    let is2 c = if c = '2' then 1 else 0 in
    let rec cnt2 l c =
        match l with
        | car::cdr -> cnt2 cdr (c + is2 car)
        | [] -> c in
    cnt2 l 0


let () =
    let n = read_line () in
    let l = explode n in
    begin
        print_int (count2 l);
        print_newline ()
    end
