program prob61
    implicit none
    character(4) :: s
    integer :: c, i
    read(*,*) s
    c = 0

    do i = 1, 4
        if(s(i:i) == '2')then
            c = c + 1
        end if
    end do
    write(*,*) c

    stop
contains
end program prob61