peterverebics/CodeNet_Python_118 huggingface dataset:
import sys

input = sys.stdin.readline

S = input().rstrip()
n = len(S)
l = [0]*2019
d = 10

t = int(S[n-1])

l[0] += 1

for i in range(n-2, -1, -1):
    t = t + int(S[i])*d
    l[t%2019] += 1 
    d *= 10

ans = 0

for i in l:
    ans += i*(i-1)//2

print(ans)
s = input()

div = int(200000/2019)

ret = 0
for i in range(1, div+1):
    l = len(str(i*2019))
    for j in range(len(s)-l+1):
        if s[j:j+l] == str(i*2019):
            ret += 1
print(ret)
z = 200000 // 2019
x = [str(2019 * (i + 1)) for i in range(z)]
# print(s)
s = input()
count = 0
for y in x:
  start = 0
  while len(s[start:]) >= len(y):
    a = s[start:].find(y)
    if a == -1:
      break
    if a >= 0:
      count += 1
      start += a + 1
print(count)
s = input()
count = 0
for i in range(891):
    tmp = i*2019
    idx = s.find(str(tmp))
    while idx != -1:
        count += 1
        idx = s.find(str(tmp), idx+1)
  
print(count)
import collections

n = input()
l = [int(x) for x in list(n)]

leng = len(l)
liste = []

x = 0
for i in range(leng):
  x += l[leng-i-1]*pow(10,i)
#  print(x)
  a = x % 2019
  liste.append(a)
#  print(a)

c = collections.Counter(liste)
m = list(c.values())
sum = 0
for i in range(len(m)):
  if m[i] != 1:
    sum += (m[i]-1)
print(sum)
digits = input()
possilist = []
for i in range(4,len(digits)):
	for j in range(0,len(digits)):
		tmp = int(digits[j:j+i])
		if tmp > 2019:
			possilist.append(tmp)
listtosettolist = list(set(possilist))
ctr = 0
for i in range(len(listtosettolist)):
	if listtosettolist [i] % 2019 == 0:
		ctr += 1
print(ctr)
S = input()
count = 0
for i in range(len(S)):
  for j in range(i+1,i+7):
    if int(S[i:j]) % 2019 == 0:
      count = count + 1
      if j >= len(S):
        break
print(count)
import sys
input=sys.stdin.readline
S=input()
l=len(S)
z=0
for x in range(l):
    for y in range(l-x-3):
        T=S[x:x+y+4]
        t=int(T)
        
        if t%3==0:
            if t%673==0:
                z+=1
            
print(z)
s = input()
ans = 0
if len(s) >= 4:
    for i in range(len(s)-3):
        if int(s[i:i+4]) %2019 ==0:
            ans += 1
if len(s) >= 5:
    for i in range(len(s)-4):
        if int(s[i:i+5]) %2019 ==0:
            ans += 1
print(ans)
k=[str(2019*(i+1))for i in range(99)]
s=input()
n=len(s)
p=0
for i in k:
    if len(i)>len(s):
        break
    for j in range(n-len(i)+1):
        if i==s[j:j+len(i)]:
            p+=1
print(p)
s = input()
keta = len(s)
ans = 0
mul = []

for i in range(100):
    if "0" in str(2019 * i):
        pass
    else:
        mul.append(str(2019 * i))

for i in range(len(mul) - 1):
    for j in range(0, keta + 1 - len(str(mul[i]))):
        if s[j : j + len(mul[i])] == mul[i]:
            ans += 1

print(ans)
s = input()
li = []
i = 2019
while int(i) < 400000:
    i += 2019
    c = str(i)
    if c in s:
        a = [x for x in range(len(s)) if s.startswith(c, x)] 
        for b in a:
            li.append(b)
print(len(li))
n = input()

m = len(n)

l = list()

c = 0

for i in range(m):
    for j in range(m-i):
        l.append(i)
        l.append(i+j+2)

for k in range(len(l)//2):
    s = n[l[2*k]:l[2*k+1]]
    s = int(s)
    
    if s % 2019 == 0:
        c += 1

print(c-1)
s = input()
n = len(s)
s_cu = [0] * n
counter = [0] * 2019

for i in range(1, n+1):
    s_cu[i-1] = int(s[n-i:]) 
    counter[int(s[n-i-1:]) % 2019] += 1
print(s_cu)

#diff
counter[0]+=1
#diff end


ans = 0
for i in counter:
    ans += (i * (i - 1)) // 2

#print([i for i in counter if i>1])
#print(counter[0])

print(ans)
S = input()

p = 7
N = len(S)
t = [0]*(N+1)
for i in range(N-1,-1,-1):
  k = (int(S[i]) * pow(10,N-i-1,p))%p
  t[i] = (t[i+1]+k)%p
t= t[:N]
cnt = [0]*p
for i in range(N):
  cnt[t[i]]+=1 
ans = 0
for i in range(p):
  m = cnt[i]
  if i == 0:
    ans = 1 + (m*(m-1))//2
  else:
    ans += (m*(m-1))//2
print(ans)
n=input()
cnt=0
i=0
while i<len(n)-4:
    flag=1
    for j in range(i+5,len(n)+1):
        if int(n[i:j])%2019==0:
            flag=0
            cnt+=1
            break
    if flag==0:
        i=j-1
    else:
        i+=1

print(cnt)
import math
s = input()
n = len(s)
count = 0
a = [0 for i in range(2019)]
a[0] = 1
k = 0
b = [0 for i in range(n)]
b[0] = 1
for i in range(1, n):
    b[i] = b[i-1]*10 % 2019

print(b)
for i in reversed(range(0, n)):
    print((b[n-i-1])*int(s[i]) % 2019)
    k += (b[n-i-1])*int(s[i]) % 2019
    print(k, k % 2019)
    a[k % 2019] += 1

for i in range(len(a)):
    if a[i] >= 2:
        count += (a[i])*(a[i]-1)//2
print(count)
S = input()
A = [0 for i in range(2019)]
x = 0
for i in range(len(S)):
    p = i + 1
    a = (int(S[-p]))*10**i % 2019
    x = (x+a) % 2019
    A[x] += 1
ans = A[i]
for i in range(2019):
    ans += A[i]*(A[i]-1)//2
print(ans)
def main():
  s=input()[::-1]
  l,mod=len(s),2019
  x=[0]*(l+1)
  x[1]=(int(s[0])*(pow(10,1,mod)))%mod
  for i in range(2,l+1):
    x[i]=((int(s[i-1])*(pow(10,i,mod)))+x[i-1])%mod
  ll=len(set(x))
  print(l-ll+1)
if __name__=='__main__':
  main()
S=str(input())
ans=0
 
for i in range(2019,2019*99+1,2019):
  for j in range(len(S)+1):
    if str(i) == S[j:j+len(str(i))]:
      print(S[j:j+len(str(i))])
      ans+=1

print(ans)
a = [str(i) for i in range(2019, 200000, 1) if i % 2019 == 0]
s = input()
ans = 0
for i in a:
    s_1 = s
    while (i in s_1):
        s_1 = s_1[s_1.find(i) + 1:]
        ans += 1
print(ans)
a=input()
counter=0
i=0
while i <len(a)-3:
    for j in range(i+3,len(a)):
        if int(a[i:j+1])%2019==0:
            counter+=1
            i=j-1
    i+=1
print(counter)
s = str(input())
length = len(s)
count = 0
first = [1, 2, 4, 6, 8]
for i in range(length - 2):
  if int(s[i])%2 in first:
    for j in range(i+3, length + 1):
      if int(s[i:j])%2019 == 0:
        count += 1
print(count)
from scipy.special import comb
from collections import Counter, deque

S = list(map(int, list(input())))
D = deque(S)
a = {}
value = 0
ten_mod = 1

for i in range(len(S)):
    value = value + D.pop() * ten_mod % 2019
    ten_mod = ten_mod * 10 % 2019
    if value % 2019 in a.keys():
        a[value % 2019] += 1
    else:
        a[value % 2019] = 1

b = [comb(i, 2, exact=True) for i in a.values() if i > 1]
print(sum(b))
l = [str(2019 * i) for i in range(1, 200001)]
s = input()
ans = 0
for i in l:
  if i in s: ans += 1
print(ans)
S = str(input())
S_int = int(S)

count = 0
  
if S_int < 2019:
  print(0)
else:
  for i in range(len(S)-3):
    test = S[i]
    for j in range(i+1,len(S)):
      test = test + S[j]
      if len(test) >= 4:
        test_int = int(test)
        if test_int % 2019 == 0:
          count = count + 1

print(count)
import collections

N_S = input()
N = int(N_S)
N_len = len(N_S)
MOD_N = [0]*N_len
Target = 0
tmp = 1

for i in range(N_len):
  Target += int(N_S[N_len-1-i])*tmp
  Target %= 2019
  tmp = tmp * 10 % 2019
  MOD_N[N_len-1-i] = Target 
  
c = collections.Counter(MOD_N)

Key = list(c.keys())
Num = list(c.values())
M = len(Key)
ans = 0

for i in range(M):
  if Key[i] == 0:
    ans += Num[i]
  else:
    ans += Num[i] * (Num[i] - 1) // 2

print(ans)
s = input()
n = len(s)
dp = [0 for _ in range(n)]
dp[-1] = int(s[-1])
tmp = 1
for i in range(n-2, -1, -1):
    dp[i] = (dp[i+1] + int(s[i]) * pow(10, (n-i-1), 2019)) % 2019

cnt_dic = {}

for i in dp:
    if not i in cnt_dic:
        cnt_dic[i] = 0

    cnt_dic[i] += 1

# print(dp)
ans = 0
# print(cnt_dic)
for i, j in cnt_dic.items():
    if i == 0:
        ans += j
    else:
        ans += j * (j - 1) // 2

print(ans)
s = input()
a = int(s)
mod_N = [0]*2019
mod_N[a%2019] += 1
for i in range(len(s)):
  a = a-int(s[i])*10**(len(s)-i-1)
  mod_N[a%2019] = 1
ans = 0
for i in mod_N:
  ans += mod_N[i]*(mod_N[i]-1)//2
print(ans)
S = input()

ans = 0
left = 0
right = 1
while left < len(S):
    while right <= len(S) and int(S[left:right]) % 2019 != 0:
        right += 1
    if int(S[left:right]) % 2019 == 0:
        ans += 1
        left = right - 1
        right += 3
    else:
        left += 1
        right = left + 1

print(ans)
# -*- coding: utf-8 -*-

def count_all(text, part):
    t = sum(1 for x in range(len(text)) if text[x:].startswith(part))
    return t

S = input()
I = 2019
count = 0

while I < 200000:
    if '0' in str(I):
        pass
    else:
        count += count_all(S,str(I))
    I += 2019
print(count)
s=input()
n=len(s)
ans=0
y=0
i=0
pe=[0]*(n+32)
pa=[0]*(n+32)
for i in range(n-3):
    if int(s[i:i+4])%2019==0:
        pe[i+3]+=pe[i]+1
        y+=1
    if int(s[i:i+5])%2019==0 and not(i==n-4):
        pe[i+4]+=pe[i]+1
        y+=1
    if y>=1:
        pe[i]=0 
    y=0
print(sum(pe))
s = str(input())
L = len(s)
dict = {}
for i in range(L):
  amari = (int(s[i:])*(10**i)) % 2019
  if not(amari in dict.keys()):
    dict[amari] = 1
  else:
    dict[amari] += 1
ans = 0
for key in dict.keys():
  ans += (dict[key]*(dict[key]-1))/2
print(int(ans))
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    s = input()
    s = s.strip()
    ans = 0
    for i in range(len(s)):
        ss = s[i]
        t = int(s[i])
        for j in range(i+1, min(len(s), i+200)):
            ss += s[j]
            t += int(s[j])
            if t % 3 == 0:
                if int(ss) % 2019 == 0:
                    ans += 1
    print(ans)


main()
s=input()
multiples = list(map(str, [2019*i for i in range(1, 100)]))
length = len(s)
ans = 0
option = [4,5,6]
for leng in option:
    for i in range(length-leng+1):
        if s[i:i+leng] in multiples:
            ans += 1
print(ans)
import numpy as np
S = input()
result_list = []
for i in range(len(S)-3):
    result_list += [int(S[i:j]) for j in range(i+4, len(S)+1)]
result_list = np.array(result_list)
result_list = result_list%2019==0
S = input()
if(len(S) < 5):
    print(0)
    exit()
cnt = 0
for i in range(len(S)-4):
    if(int(S[i:i+5]) % 2019 == 0):
        cnt += 1
    if(len(S)-i >= 6 and S[i] == '1'):
        if(int(S[i:i+6]) % 2019 == 0):
            cnt += 1
print(cnt)
s=input()
l=[0]*2019
d=1
x=0
for i in range(1,len(s)+1):
  x+= d* int(s[-i]) 
  x%=2019
  l[x]+=1
  d*=10
  d%=2019
ans=0
if x==0:
  ans-=1
for i in range(1,2019):
  ans+=l[i]*(l[i]-1)//2
print(ans+l[0])
import collections

N_S = input()
N = int(N_S)
N_len = len(N_S)
MOD_N = [0]*N_len
Target = 0
tmp = 1

for i in range(N_len):
  Target += int(N_S[N_len-1-i])*tmp
  Target %= 2019
  tmp = tmp * 10 % 2019
  MOD_N[N_len-1-i] = Target 
  
print(MOD_N)
c = collections.Counter(MOD_N)

Key = list(c.keys())
Num = list(c.values())
M = len(Key)
ans = 0

for i in range(M):
  if Key[i] == 0:
    ans += Num[i]
  else:
    ans += Num[i] * (Num[i] - 1) // 2

print(ans)
s=input()
i=1
j=5
count=0
while i<len(s)-4:
    a=int(s[i-1:j])
    if a%2019 == 0:
        count+=1
    if j>=len(s):
        i+=1
        j=i+4
    else:
        j+=1      
        
print(count)
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

s = input()
ans = 0
same = []
l = [str(i*2019) for i in range(1, 100)]
for i in l:
    if i in s:
        same.append(i)
        ans += 1
for i in same:
    j = 0
    m = s
    ans -= 1
    for _ in range(len(s)):
        idx = m.find(i)
        m = m[idx+1:]
        if idx==-1:
            break
        ans += 1
print(ans)
s = input()
n = 2019

c = 0
for i in range(1, 1000):
    st = str(n*i)
    j = 0
    while j <= (len(s)-len(st)+1):
        if st in s[j:]:
            ind = s[j:].index(st)
            c+=1
            j = ind+j+1
        else:
            break
      
print(c)
# 2019 = 3*673
MOD = 2019
S = input()
N = len(S)
X = [0]*2100
X[0] += 1
tmp = 0
hoge = pow(10,N,2019)

for i in range(N):
    tmp = tmp*10+int(S[i])
    hoge = (hoge*202)%MOD 
    X[(tmp*hoge)%MOD] += 1   

ans = 0

for i in X:
    if i >= 2:
        ans += i-1

print(ans)
S=input()
S1=int(S)
#print(len(S))
S_count=len(S)
sum=0
sum1=0
ii=0
jj=4
SSSS=int(S_count)
for i in range(S_count):
  sum1+=i
#print(sum1)
for i in range(sum1):
  if ii==int(S_count-3):
    break
  SS=S[ii:jj]
  print(SS)
  SSS=int(SS)
  if SSS%2019==0:
    sum+=1
  jj+=1
  if jj==int(S_count+1):
    ii+=1
    if ii>=4:
      jj=ii+1
    else:
      jj=4
  
print(sum)
import math

def readInt():
	return int(input())

def readInts():
	return list(map(int, input().split()))

def readChars():
	return input().split()

s = input()

ai = [0]*len(s)
si = [0]*len(s)

p = 2019

for i in range(len(s)):
	ai[i] = (int(s[-1*i-1])*pow(10,i))%p
	si[i] = sum(ai[:i+1])%p
countarr = [0]*2019
S = input()
n = len(S)
count = 0
for i in range(0,n-3):
    s = S[i:i+4]
    for j in range(i+4,n):
        s = s + S[j]
        print(s)
        if int(s)%2019 == 0 : count += 1
print(count)
import sys

s = str(input())
tisa = []
for i in range(1,100):
  tisa.append(str(2019*i))
#ok
#print(s)
#print(tisa)
ans = 0
for c in tisa:
  for i in range(0,len(s)-len(c)+1):
    if s[i:i+len(c)]==c:
      ans += 1

  

print(ans)
#! env/bin/local python3
# -*- coding:utf-8 -*-

import math

def main():

    inp = input().strip('\n')
    number_of_digit = len(inp)
    n = int(inp)

    print(math.factorial(number_of_digit))

    for i in range(math.factorial(number_of_digit)):
        a = 0


if __name__ == '__main__':
    main()
S=input()
mem_mod = [0 for i in range(0,2019,1)]
N = len(S)
counter = 0
S_num_tmp = list(S)
S_num = list(map(int, S_num_tmp))
tmp=10

for i in reversed(range(1,N,1)):
    tmp=tmp*10
S=str(input())
n=0
for i in range(len(S)-3):
  j=i+3
  m=S[i:j]
  a=int(S[i])+int(S[i+1])+int(S[i+2])
  r=a%3
  while j<=len(S)-2:
    m=S+str(S[j+1])
    r=(r+int(S[j+1]))%3
    if r==0:
      if int(m)%2019==0:
        n+=1
      else:
        pass
    j+=1
print(n)
s = input()
i, j = 0, len(s)-1
cnt = 0
while i < j:
    num = int(s[i:j+1])
    if num % 2019 == 0:
        cnt += 1
        j = i
        i = 0
    else:
        i += 1
print(cnt)
s = str(input())[::-1]

tmp_amari = [0]*2019

#amari = 0
num = 0
order = 1
for i in s:
    num += int(i)*order
    num = num % 2019
    #print(num)
    tmp_amari[num] += 1
    order *= 10

#tmp_print = [i for i in tmp_amari if i > 0]
#print(tmp_print)

ans = 0
ans += tmp_amari[0]

for i in range(1,2019):
    n = tmp_amari[i]
    ans += n*(n-1)//2

print(ans)
from collections import Counter
S = input()
#S = S + '0'
mod = 2019
p = [0] * mod
r = 0
d = 1
for s in S[::-1]:
  t = int(s)%mod
  r += t*d
  r %= mod
  d = d*10%mod
  p[r] += 1

p.append(0)
ans = 0
c = Counter(p)
for k,n in c.most_common():
  if n > 1:
    ans += 1
  else:break
print(ans)
s=input()
n=len(s)
sn=[0]*n
x=pow(10,n-1)
for i in range(n):
    sn[i]=int(s[i])*x
    x=x//10
from collections import Counter

sn = list(map(int, list(input())))
n = len(sn)

tmp = 0
mn = [None] * n
for i in range(n):
    j = n - i - 1
    tmp += (sn[j] * 10 ** i) % 2019
    mn[j] = tmp 
mn.append(0)

counter = Counter(mn)
ans = 0
for c in counter.values():
    if c >= 2:
        ans += c * (c - 1) // 2
    
print(ans)
s=input()
lis=[]
for i in range(1,500):
    if '0' in str(2019*i):
        pass
    else:
        lis.append(2019*i)
        
ngram=[]
for i in range(5,7):
    l=[]
    for j in range(len(s)-i+1):
        l.append(s[j:j+i])
    ngram.append(l)
    
print(ngram)

ans=0
for i in lis:
    ans+=ngram[len(str(i))-5].count(str(i))
print(ans)
S = str(input())
N = len(S)
count = 0

if N < 4:
    print(0)
else:
    for i in range(N-3):
        r = int(S[i:i+4])%2019 
        if r == 0:
            count += 1
        if N > 4:
            for j in range(i+4, N):
                r = (r*10 + int(S[j])) % 2019
                if r == 0:
                    count += 1

print(count)
s = input()
s = list(reversed(s))
n = len(s)
dp1 = [0]*n
dp2 = [0]*n
counting = [0]*2019
dp1[0] = 1
dp2[0] = int(s[0])
counting[dp2[0]] += 1
if n >= 2:
    for i in range(1,n):
        dp1[i] = (10*dp1[i-1]) % 2019
        dp2[i] = (int(s[i])*dp1[i]+dp2[i-1]) % 2019
        counting[dp2[i]] += 1
sm = 0
for j in range(2019):
    sm += int(counting[j]*(counting[j]-1)/2)
print(sm)
s=list(map(int,list(input())))[::-1]

n=len(s)
D=[0]*(n+1)
c=[0]*(n+1)

# print(s)
# print(D)
S = s[0]
c[0] = S
for e,i in enumerate(s):
    if e==0:continue
    c[e] = (S)%2019
    S = i*pow(10,e)+S
# print(c)
ans = 0
f = 0
dp = [0]*(2020)
for e,i in enumerate(c):
    ans +=dp[i]
    dp[i]+=1
print(ans)
S = input()
ans = 0
for i in range(4,min(len(S),10)):
    for i2 in range(0,len(S) - i + 1):
        if int(S[i2:i2 + i]) % 2019 == 0:
            ans += 1
print(ans)
s = input()

s0 = 0
for i in range(len(s)):
    for j in range(len(s)):
        if i + 3 <= j:
            if int(s[i:j]) % 2019 == 0:
                s0 += 1
print(s0)
s = input()
s = list(reversed(s))
n = len(s)
dp1 = [0]*n
dp2 = [0]*n
counting = [0]*2019
dp1[0] = 1
dp2[0] = int(s[0])
counting[dp2[0]] += 1
if n >= 2:
    for i in range(1,n):
        dp1[i] = (10*dp1[i-1]) % 2019
        dp2[i] = (int(s[i])*dp1[i]+dp2[i-1]) % 2019
        counting[dp2[i]] += 1
sm = 0
for j in range(2019):
    sm += counting[j]*(counting[j]-1)/2
print(sm)
from itertools import product

s='1817181712114'
n=0
ss=len(s)

i = range(0, ss-3)
j = range(3, ss+1)


for i,j in product(i,j):
    if i<j:
        if int(s[i:j])%2019==0:
            n+=1
print(n)
s=input()
num=2019
count=0
for i in range(len(s)-3):
    for j in range(i+3,i+3+2):
        target=int(s[i:j+1])
        if target%num==0:
            count+=1
print(count)
s =input()
l=[]

for i in range(1,200000//2019+1):
    l.append(str(i*2019))

import collections

len_text = len(s)
dic = collections.defaultdict(int)
for i in range(1,7):
    for j in range(len_text-i+1):
        dic[s[j:j+i]] += 1
total = 0
for i in l:
    total += dic[i]
print(total)
import collections
s=input()
n=len(s)
a=[]
x=0
p=1
for i in range(n):
	j = n-1-i
	c = int(s[j])
	p *= 10
	p %= 2019
	x += (p*c)%2019
	x %= 2019
	a.append(x)
c=collections.Counter(a)
ans = 0
for k,v in c.items():
	if k==0:
		ans += v
	else:
		ans += v*(v-1)//2
print(ans)
s=int(input())
s2 = str(s)
multiples = list(map(str,[2019*i for i in range(1, 100)]))
length = len(s2)
ans = 0
option = [4,5,6]
for leng in option:
    for i in range(length-leng+1):
        if s2[i:i+leng] in multiples:
            ans += 1
print(ans)
S = input()
s = len(S)
ss = 5
cnt = 0
if s<5:
  print(0)
else:
  while ss != s:
    for i in range(s-ss+1):
      if int(S[i:i+ss])%2019==0:
        print(S[i:i+ss])
        cnt += 1
        i += ss-1
    ss += 1
  print(cnt)
s = input()
count = 0
for i in range(len(s)+1):
    for j in range(i+1, len(s)+1):
        if (int(s[i:j])%3 == 0 and int(s[i:j])%673 == 0):
            count += 1
            print("ok", s[i:j])
print(count)
s = input()
ls = [str((i+1) * 2019) for i in range(int(200000 // 2019))]
c = 0
for i in ls:
    for pos in range(len(s)):
        if s[pos:].startswith(i):
            c += 1
print(c)
s=input()
# print(len(s));
i=0
count=0
for j in range(5,len(s)+1):
    
    m=s[i:j]
    
    # print(int(m))
    if int(m)%2019==0:
        count+=1
    i=i+1

print(count)
S = input()
ans = 0
k = 0
l = 3

for i in range(k,len(S)):
    for j in range(l,len(S)):
        if i!=j and i <= j:
            if int(S[i:j+1]) % 2019 == 0:
                ans+=1
                k = i
                l = j
                print(i,j)
print(ans)
s = input("")
l = ['2019', '4038', '6057', '8076', '10095', '12114', '14133', '16152', '18171']
res = []
for i in range(len(s)):
	s2 = s[i:]
	for i in l:
		b = s2.find(i)
		if b!= -1:
			e = b+ len(i)
			b = b +1
			res.append((b, e))
#print(res)
print(len(res))
s=str((input()))
k=2019
list=[]
while(k<=200000):
    list.append(str(k))
    k+=2019
ans=0
for x in range(len(s)):
    for y in range(x,min(x+6,len(s))):
        t=s[x:y+1]
        if t in list:
            ans+=1
print(ans)
S = input()
ans = 0

for a in range(2019, 200000,2019):
    d = len(str(a))
    if d > len(S):
        break
    for i in range(0, len(S) - d + 1):
        j = i + d
        if int(S[i:j]) == a:
            ans += 1

print(ans)
S = input()

ans = 0
num = 2019

for i in range(1000):
    s_num = str(num)
    begin = S.find(s_num)
    while begin >= 0:
        ans += 1
        begin = S.find(s_num, begin + 1)
    num += 2019

print(ans)
s = input()

a = []
for i in range(1,1001):
  a.append(str(i * 2019))
ans = 0
for i in a:
    if i[0] == i[-1]:
        count = s.count(i[:-1])
    elif i[0:2] == i[-2:]:
        count = s.count(i[:-2])
    elif i[0:3] == i[-3:]:
        count = s.count(i[:-3])
    else:
        count = s.count(i)
    ans += count
      
print(ans)
s=input()
S=int(s)
st=0
sums=0
for i in range(99):
    a=str(2019*(i+1))
    for j in range(len(s)-len(a)+1):
        if int(s[j:j+len(a)])-int(a)==0:
            st=st+1
        else:
            g=0
            
            
            
    
print(st)
import scipy as sp
from collections import Counter

s = input()
ans = 0
s_i_list = list()

for i in range(len(s)):
    s_i_list.append(int(s[i:]) % 2019)

scount = Counter(s_i_list)

for i in scount.values():
    ans += i*(i-1)//2

print(ans+1)
s=input()
n=len(s)
rst=[0 for j in range(2019)]
x=0
ans=0
drst=1
for i in range(n):
    y=int(s[n-1-i])*drst%2019
    drst=(drst*10)%2019
    x+=y
    if x>=2019:
        x%=2019
    #print(x,y)
    ans+=rst[x]
    rst[x]+=1
if rst[0]==1:
    ans+=1

print(ans)
S = input()

def check_2019(txt):
  amari = int(txt) % 2019
  if amari == 0:
    return True
  else:
    return False

N = len(S)

ans = 0

i = 0
j = i + 4

while(i <= N-2):
  j = i + 4
  while(j <= N+1):
    if check_2019(S[i:j]):
      ans += 1
      i = j
      break
    j += 1
  i += 1

print(ans)
a = input()
b = 0
if int(a) < 2019:
    print(0)
else:
    for i in range(len(a)-3):
        c = a
        if int(c) % 2019 == 0:
            b += 1
        for j in range(len(a)-4):
            c = a[:-j-1]
            if int(c) % 2019 == 0:
                b += 1
        a = a[1:]
print(b)
def d164(n):

    ans = 0
    for i in range(1, 200000):
        count = 2019*i
        if n.count(str(count)) != 0:
            ans += n.count(str(count))
    return ans

def main():
    n = str(input())
    print(d164(n))
if __name__ == '__main__':
    main()
from collections import deque
#import time

#start = time.time()#計測始
s = str(input())

n=len(s)
span=1
mlist=deque("0")
slist=""

while span<n+1:
  slist = s[n-span] + slist
  #print(str(slist))
  m = int(slist)%2019
  mlist.append(m)
  span+=1
  

ll=len(mlist)

l=len(set(mlist))
#end = time.time()#計測終
print(ll-l)

#print(f"{end-start}sec.")#計測出力
a=input()
list1=[]
current_num=int(a[-1])%2019
length=len(a)
list1.append(current_num)
for i in range(2,len(a)) :
    
    current_num=(int(a[-i]) * 10 + current_num) % 2019
    list1.append(current_num)
count=0



count=0
list1.append(0)
import collections
c=collections.Counter(list1)
list2=c.values()
count=0
for item in list2 :
    count+=(int(item*(item-1)/2))


print(count)
string=input()
length=len(string)
mod=[1]*2019
while length > 0:
  mod[int(string[length-1:])%2019]+=1
  length-=1
print(int(sum([(i*(i-1))/2 for i in mod])))
S = input()
ans = 0
for i in range(len(S)):
    for j in range(20):
        if i+j+1 > len(S): break
        if int(S[i:i+j+1]) % 2019 == 0:
            ans += 1
print(ans)
S = input()
num = int(S[0])
check = 1
count = 0
for i in range(len(S)):
    while num <= 200000:
        if num % 2019 == 0 :
            count += 1
        #print(num)
        try:
            num = num*10 + int(S[i+check])
        except:
            break
        check += 1
        #print(count)
    try:
        num = int(S[i+1])
    except:
        break
    check = 1
print(count)
s = input()
cnt = 0
 
for i in range(0,len(s)-3):
    if (int(s[i+1])%2!=0)or((int(s[i])!=1)and(int(s[i])%2!=0)):
        continue
    for j in range(i+4,len(s)+1):
        a = s[i:j]
        print(a)
        if int(a)%2019==0:
            cnt += 1
 
print(cnt)
S = input()
# S = '1817181712114'
# S = '14282668646'
# S= '2119'

cnt = 0
for i in range(len(S)):
    for length in range(4, len(S) - 4):
        window = S[i:i + length]
        if len(window) == length:
            if int(window) % 2019 == 0:
                # print('baisu found', int(window))
                cnt += 1

print(cnt)
s=input()
n=len(s)
count=0
#for j in range(n-3):
j=0
while j<n-3:
	i=4
	while(i<n-j+1):
	#for i in range(4,n+1-j):
		nu = int(s[j:i+j])
		#print(nu) 
		if nu%2019==0:
			count+=1
			j+=3
			break

		i+=1
	j+=1
print(count)