Imports System.Collections
Imports System.Collections.Generic
Imports System.Linq
Imports System.xml
Imports System.xml.Linq

Module Module1
	public sub main()

    dim D as string = Console.ReadLine()
    
    dim cnt as integer = 0
    for i = 0 to D.length - 1
    	for j = i to D.length -1
		    if j-i +1 > "200000".length then
    		  exit for
    		end if
    
    		dim a as integer =convert.toint32(D.substring(i,j-i+1))
		    if 200000 < a then 
		      exit for
		    end if
    		if a mod 2019 = 0 then
    		  cnt += 1
	  		end if
  		next
  	next
    console.writeLine(cnt)
end sub
End Module