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
   			dim a as long =Long.Parse(D.substring(i,j-i+1))
    		if a mod 2019 = 0 then
    		  cnt += 1
	  		end if
  		next
  	next
    console.writeLine(cnt)
end sub
End Module