program main
    implicit none
    character(200001) S, sub_S
    integer i, j, S_len, m
    integer(8) num, ans
    m = 2019
    ans = 0
    read *, S
    S_len = len_trim(S)
    do i = 4, S_len
        do j = 1, S_len - i + 1
            sub_S = S(j:j + i - 1)
            read (sub_S, *) num
            if (mod(num, m) == 0) then
                ans = ans + 1;
            end if
        end do
    end do
    print '(I0)', ans
    stop
contains

end program main