program ABC164_D
  character(200000)::S
  integer::k
  read(*,*)S
  N=len_trim(S)
  cnt=0
  do i=1,N-3
     do j=i+3,N
        read(S(i:j),*)k
        if(mod(k,2019)==0) then
           cnt=cnt+1
           exit
        end if
     end do
  end do
  write(*,*)cnt
end program ABC164_D