import math
s = input()
l = len(s)
cnt = 0
for i in range(l-1):
    for j in range(i+1, l):
        if eval(s[i:j+1]+'/2019') - math.floor(eval(s[i:j+1]+'/2019')) == 0:
            cnt += 1

print(cnt)
