program sample
	implicit none
    character(len=4) ::x
    integer ::count,i
    
    read(*,*) x
    do i=1,4
    	if(x(i:i)=='2') then
        	count = count+1
        end if
    end do
    
    write(*,*) count
    
    stop
end program sample