with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   N : Integer;
   A : Integer;
   Count : Integer;
begin
   Get (N);
   Count := 0;
   for I in 1 .. 4 loop
      A := N-N/10*10;
      if A = 2 then
         Count := Count+1;
      end if;
      N := N/10;
   end loop;
   Put_Line (Integer'Image (Count));
end Solve;