program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,i,l,ans,j,sek,keta,nlist(200000/2019)
    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)
        write(bs,*)nlist(i)
        bs=adjustl(bs)
        l = len_trim(bs)
        if (l > n) cycle
        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 