program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,l,ans,j
    integer(int32), allocatable:: a(:)
    character(200000):: s,bs

    read*, s
    n = len_trim(s)

    allocate(a(n))
    ans=0
    do while(i*2019 <= 200000)
        i=i+1
        write(bs,*) 2019*i
        bs = adjustl(bs)
        l = len_trim((bs))

        do j=1,n-l+1
            if (s(j:j+l-1) == trim(bs)) ans=ans+1 
        end do
    end do

    print'(i0)', ans

end program 