s = input()
cnt = 0
num_list = []
list4 = []
for i in range(1,10001):
    num_list.append(i*2019)
    list4.append(int(str(i*2019)[-4::]))
for j in range(0,len(s)-4+1):
    if int(s[0+j:4+j]) in list4:
        
        if s[4+j-len(str(num_list[list4.index(int(s[0+j:4+j]))])):4+j] == str(num_list[list4.index(int(s[0+j:4+j]))]):
            cnt += 1
            
print(cnt)