let S = readLine()!

var r = 0
for i in S.indices {
    let m = S.index(i, offsetBy: 18, limitedBy: S.endIndex) ?? S.endIndex
    for j in S[i..<m].indices {
        if Int(S[i...j])!.isMultiple(of: 2019) {
            r += 1
        }
    }
}

print(r)
