program one
  implicit none
  integer :: i
  integer :: num, count

  read(*,*)num
  count=0
  do i=1,9
     if (i*1000<=num .and. num<(i+1)*1000) then
        num=num-i*1000
        if (i==2) then
           count=count+1
        end if
     end if
  end do
  do i=1,9
     if (i*100<=num .and. num<(i+1)*100) then
        num=num-i*100
        if (i==2) then
           count=count+1
        end if
     end if
  end do
  do i=1,9
     if (i*10<=num .and. num<(i+1)*10) then
        num=num-i*10
        if (i==2) then
           count=count+1
        end if
     end if
  end do
  if (num==2) then
     count=count+1
  end if

  write(*,*)count

end program one