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 - 3
            Dim tmpStr As String = S.Substring(i_pos, 3)
            Dim tmpSum As Integer = 0
            For Each c As Char In tmpStr
                tmpSum = tmpSum + CInt(c.ToString())
            Next
            For j_pos As Integer = 3 To S.Length - i_pos - 1
                Dim tmpChr As String = S.Substring(j_pos + i_pos, 1)
                tmpStr = tmpStr & tmpChr
                tmpSum = tmpSum + CInt(tmpChr)
                If tmpSum Mod 3I = 0I Then
                    Dim tmpDbl As Double = CDbl(tmpStr)
                    If tmpDbl Mod 2019 = 0 Then retCount = retCount + 1
                End If
            Next
        Next

        Console.WriteLine(retCount.ToString())

    End Sub

End Module