Module Program

    Sub Main(args As String())

        Dim S As String = Console.ReadLine()

        Dim retCount As Integer = 0
        For i_pos As Integer = 0 To S.Length - 4
            For strLen As Integer = 4 To S.Length - i_pos
                Dim tmpStr As Double = CDbl(S.Substring(i_pos, strLen))
                If tmpStr Mod 2019 = 0 Then retCount = retCount + 1
            Next
        Next

        Console.WriteLine(retCount.ToString())

    End Sub

End Module