program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,i,l,ans,j,nlist(99)
    character(200000):: s,bs

    read*, s
    n = len_trim(s)

    ans=0
    i=1

    do i=1, size(nlist)
        nlist(i) = 2019*i
    end do

    do i=1, size(nlist)
        l = int(log10(dble(nlist(i))))+1
        do j=0,l-1
            bs(l-j:l-j) = char(mod(nlist(i)/(10**j),10_8)+ichar('0'))
        end do
        do j=1,n-l+1
            if (s(j:j+l-1) == bs(1:l)) ans=ans+1 
        end do
    end do
    print'(i0)', ans
end program 