Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

r,g,b,n = map(int,input().split())

ans = 0
for i in range(3001):
    for j in range(3001):
        if (n-r*i-g*j) < 0:
            break
        if (n-r*i-g*j)%b == 0:
            ans += 1
print(ans)

### FIXED CODE ###

r,g,b,n = map(int,input().split())
 
ans = 0
for i in range(n//r+1):
    for j in range((n-r*i)//g+1):
        if (n-r*i-g*j)%b == 0:
            ans += 1
print(ans)
### BUGGY CODE ###

N, M = [int(x) for x in input().split()]

AB = [0] * N
for i in range(N):
    A, B = [int(x) for x in input().split()]
    AB[i] = (A, B)

# 期間が短い報酬が高い
def key(ab):
    a, b = ab
    return -b, a
AB = sorted(((a, b) for a, b in AB if a <=M), key=key)
#print(BA)

def calc(jobs, M):
    m = 0
    for d, (a, b) in enumerate(jobs):
        if d + a <= M:
            m += b
    return m

def check(N, M, AB):
    from itertools import permutations
    return max(calc(jobs, M) for jobs in permutations(AB))

def solve(N, M, AB):
    pass

def solve(N, M, AB):
    # a = 1 -> M - a
    d = M
    i = 0
    score = 0
    scheduled = set()
    for d in range(0, M+1)[::-1]:
        for i, (a, b) in enumerate(AB):
            if i in scheduled:
                continue
            #print("d=%d"%d,(a,b),d+a,end="")
            if d + a <= M:
                score += b
                #print(" score=%d"%score)
                d -= 1
                scheduled.add(i)
                break
    return score

#print("check", check(N, M, AB))
print(solve(N, M, AB))


### FIXED CODE ###

import heapq

N, M = [int(x) for x in input().split()]
AB = [0] * N

for i in range(N):
    AB[i] = [int(x) for x in input().split()]

AB = sorted(AB)

jobs = set()
answer = 0
nextpush = 0
candidates = []

for day in range(M)[::-1]:
    while nextpush < N:
        a, b = AB[nextpush]
        if day + a <= M:
            heapq.heappush(candidates, (-b, a))
            nextpush+=1
        else:
            break
    if candidates:
        b, a = heapq.heappop(candidates)
        answer -= b
print(answer)
### BUGGY CODE ###

n = int(input())
a = ["".join(sorted(input())) for i in range(n)]
cnt = 0
for i in range(n):
	for j in range(i+1,n):
		if a[i] == a[j]:
			cnt += 1
print (cnt)


### FIXED CODE ###

n = int(input())
s = []
d = {}
for i in range(n):
	x = input()
	l = list(x)
	list.sort(l)
	ll = "".join(l)
	if ll in d:
		d[ll] += 1
	else:
		d[ll] = 1

ans = 0
for i in d:
	ss = d[i]
	if d[i] >= 2:
		ans += ss*(ss-1)/2
print (int(ans))
### BUGGY CODE ###

s = input()
cnt=0
while True:
    for i in range(len(s)//2):
        try: 
            if '10' in s:
                s=s.replace('10', '',1) 
                cnt+=2
        except:
            pass
        try: 
            if '01' in s:
                s=s.replace('01', '',1) 
                cnt+=2
        except:
            pass
    break
print(cnt)

### FIXED CODE ###

#120 C
S =input()
print(min(S.count('0'),S.count('1'))*2)
### BUGGY CODE ###

import math

H,N=map(int,input().split())
A_list=[]
B_list=[]
for i in range(N):
    A,B=map(int,input().split())
    A_list.append(A)
    B_list.append(B)

amax=max(A_list)

inf=float('inf')
dp=[0]+[inf]*(H+amax)

for i in range(N):
    A=A_list[i]
    B=B_list[i]
    if A > H and B<dp[-1]:
        dp[-1]=B
        continue

    for j in range(A,1+H):
        if dp[j-A]+B<dp[j]:
            dp[j]=dp[j-A]+B
    
    for j in range(H-A,1+H):
        if dp[j] +B < dp[-1]:
            dp[-1]=dp[j]+B

print(dp[-1])


### FIXED CODE ###

import math

def main():
    H,N=map(int,input().split())

    inf=float('inf')
    dp=[0]+[inf]*H

    for i in range(N):
        A,B=map(int,input().split())
        if A>=H:
            #dp[-1]=min(B,dp[-1])
            if B < dp[-1]:
                dp[-1]=B
        else:
            for j in range(A,H+1):
                #dp[j]=min(dp[j-A]+B,dp[j])
                if dp[j-A]+B<dp[j]:
                    dp[j]=dp[j-A]+B

                if j > H-A:
                    #dp[-1]=min(dp[-1],dp[j]+B)
                    if dp[j]+B < dp[-1]:
                        dp[-1]=dp[j]+B

    print(dp[-1])

main()
### BUGGY CODE ###

import fractions
import functools

MOD = int(1e9) + 7


class Inv:

    @classmethod
    def pow(cls, x: int, n: int) -> int:
        ret = 1
        while n > 0:
            if n % 2 == 1:
                ret = ret * x % MOD
            x = x * x % MOD
            n >>= 1
        return ret

    @classmethod
    def inv(cls, x: int) -> int:
        return cls.pow(x % MOD, MOD - 2)


N = int(input())
A = list(map(int, input().split()))

MAX_A = 1000010

facts = [0] * MAX_A

for a in A:
    i = 2
    while i <= a:
        if a % i == 0:
            c1 = 0
            while a % i == 0:
                c1 += 1
                a //= i

            facts[i] = max(facts[i], c1)
        i += 1

tar = 1
for idx, c in enumerate(facts):
    if c == 0:
        continue
    tar *= Inv.pow(idx, c)
    tar %= MOD

ans = 0
for a in A:
    ans += tar * Inv.inv(a) % MOD
    ans %= MOD

print(ans)

### FIXED CODE ###

import fractions
import functools

MOD = int(1e9) + 7


class Inv:

    @classmethod
    def pow(cls, x: int, n: int) -> int:
        ret = 1
        while n > 0:
            if n % 2 == 1:
                ret = ret * x % MOD
            x = x * x % MOD
            n >>= 1
        return ret

    @classmethod
    def inv(cls, x: int) -> int:
        return cls.pow(x % MOD, MOD - 2)


N = int(input())
A = list(map(int, input().split()))

MAX_A = 1000010

facts = [0] * MAX_A
p = [False] * MAX_A

def prime():

    for i in range(2, MAX_A):
        p[0] = p[1] = True
        if not p[i]:
            j = 2 * i
            while j < MAX_A:
                p[j] = True
                j += i

prime()

for a in A:
    i = 2
    while i * i <= a:
        if a % i == 0:
            ii = a // i
            c1 = 0
            while a % i == 0:
                c1 += 1
                a //= i
            c2 = 0
            while not p[ii] and a % ii == 0:
                c2 += 1
                a //= ii
            facts[i] = max(facts[i], c1)
            facts[ii] = max(facts[ii], c2)
        i += 1
    if not p[a]:
        facts[a] = max(facts[a], 1)

tar = 1
for idx, c in enumerate(facts):
    if c == 0:
        continue
    tar *= Inv.pow(idx, c)
    tar %= MOD

ans = 0
for a in A:
    ans += tar * Inv.inv(a) % MOD
    ans %= MOD

print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()
n = int(input())
aa = [int(i) for i in input().split()]
e = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = [int(i) - 1 for i in input().split()]
    e[a].append(b)
    e[b].append(a)

dp = [10 ** 18] * (n + 10)
dp[0] = 0
ans1 = [0] * n
ans2 = [0] * n


def dfs(i=0, r=-1):
    mi = 0
    ma = n
    while mi != ma:
        mm = (mi + ma) // 2
        if dp[mm] >= aa[i]:
            ma = mm
        else:
            mi = mm + 1

    be = dp[mi]
    dp[mi] = min(dp[mi], aa[i])
    ans1[i] = mi
    ans2[i] = max(ans1[i], ans2[r])

    for j in e[i]:
        if j == r:
            continue
        dfs(j, i)

    dp[mi] = be


dfs()
for i in ans2:
    print(i)


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)


def input():
    return sys.stdin.readline()


n = int(input())
aa = {}
for j,i in enumerate(map(int,input().split())):
    if i in aa:
        aa[i].append(j)
    else:
        aa[i] = [j]
a = [0] * n
for k,i in enumerate(sorted(list(aa))):
    for j in aa[i]:
        a[j] = k+1


class SegmentTree:
    def __init__(self, a, func=max, one=-10 ** 18):
        self.logn = (len(a) - 1).bit_length()
        self.n = 1 << self.logn
        self.func = func
        self.one = one

        self.b = [self.one] * (2 * self.n - 1)
        for i, j in enumerate(a):
            self.b[i + self.n - 1] = j
        for i in reversed(range(self.n - 1)):
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def get_item(self, i):
        return self.b[i + self.n - 1]

    def update(self, index, x):
        i = index + self.n - 1
        self.b[i] = x
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def update_func(self, index, x):
        i = index + self.n - 1
        self.b[i] = self.func(self.b[i], x)
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def get_segment(self, l, r):
        l += self.n
        r += self.n
        s = self.one
        while l < r:
            if r & 1:
                r -= 1
                s = self.func(s, self.b[r - 1])
            if l & 1:
                s = self.func(s, self.b[r - 1])
                l += 1
            l >>= 1
            r >>= 1
        return s


e = [[] for _ in range(n)]
for _ in range(n - 1):
    aa, bb = [int(i) - 1 for i in input().split()]
    e[aa].append(bb)
    e[bb].append(aa)
seg = SegmentTree([0] * (max(a)+2), max, 0)
ans1 = [0] * n
ans1[0] = 1
ans2 = [0] * n
ans2[0] = 1


def dfs(i=0, r=-1):

    y = seg.get_segment(0, a[i])
    ans1[i] = y + 1
    ans2[i] = max(ans2[r], ans1[i])

    be = seg.get_item(a[i])
    seg.update_func(a[i], ans1[i])
    for j in e[i]:
        if j == r:
            continue
        dfs(j, i)
    seg.update(a[i], be)


dfs()
print("\n".join(map(str,(ans2))))
### BUGGY CODE ###

# -*- coding: utf-8 -*-

(N, X, Y) = (int(i) for i in input().split())

# まずは経路情報をd[N][N]の二次元配列に格納
# (i, j)がつながっていれば1, つながってなければ2*10^3

d = []
for i in range(N):
    d.append([2 * 10**3]*N)

for i in range(N - 1):
    d[i][i] = 0
    d[i][i+1] = 1
    d[i+1][i] = 1

d[X-1][Y-1] = 1
d[Y-1][X-1] = 1
#print(d)

# ワーシャル・フロイドで全点の最短経路を計算
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

#print(d)

# dの全リストを連結してあとは0~N-1までカウントする
d_list = []
for i in range(N - 1):
    d_list += d[i][i+1:]

#print(d_list)

for i in range(1, N):
    count = d_list.count(i)
    print(count)

### FIXED CODE ###

# -*- coding: utf-8 -*-
from collections import Counter

def update_distance(d, num, N):
    minn = num
    maxx = num
    # 要素数の小さい方に向けて
    while True:
        if minn > 0:
            minn -= 1
        else:
            break
        if d[minn] > d[minn+1] + 1:
            d[minn] = d[minn+1] + 1
        else:
            break
    # 要素数の大きいほうに向けて
    while True:
        if maxx < (N - 1):
            maxx += 1
        else:
            break
        if d[maxx] > d[maxx-1] + 1:
            d[maxx] = d[maxx-1] + 1
        else:
            break

(N, X, Y) = (int(i) for i in input().split())
X = X-1
Y = Y-1

# まずは経路情報をd[N][N]の二次元配列に格納
# (i, j)がつながっていれば1, つながってなければ2*10^3

d = []
for i in range(N):
    dd = []
    for j in range(N):
        dd.append(abs(i - j))
    d.append(dd)

# XとYがつながることで最短経路を修正していく
for i in range(N):
    dd = d[i]
    dd[X] = min(dd[X], dd[Y] + 1)
    dd[Y] = min(dd[Y], dd[X] + 1)
    update_distance(dd, X, N)
    update_distance(dd, Y, N)

# dの全リストを連結してあとは0~N-1までカウントする
d_list = []
for i in range(N - 1):
    d_list += d[i][i+1:]

#print(d_list)
c = Counter(d_list)

for i in range(1, N):
    if i in c:
        print(c[i])
    else:
        print(0)
### BUGGY CODE ###

def changeStr(in_str, tgt_idx):
    work_str = ""

    # Left
    if tgt_idx != 0:
        work_str = in_str[:tgt_idx]

    # Target
    if in_str[tgt_idx] == "W":
        work_str = work_str + "BW"
    else:
        work_str = work_str + "WB"
    
    # Right
    if tgt_idx < len(in_str) -2:
        work_str = work_str + in_str[tgt_idx+2:]
    
    return work_str

# Input
s = input()

idx = 0
sav_idx = -1
cnt = 0
while idx < len(s)-1:

    if idx == sav_idx:
        idx += 1
    # BW or WB
    if (s[idx] == "B" and s[idx+1] == "W") or (s[idx] == "W" and s[idx+1] == "B"):
        s = changeStr(s, idx)

        cnt += 1
        sav_idx = idx
        idx -= 1
        if idx < 0:
            idx = 0

    # BB or WW
    else:
        idx += 1
# Output
print(cnt)

### FIXED CODE ###

# 2020/05/02
# AtCoder Grand Contest 029 - A

# Input
s = input()

sidx = len(s) - 1
bidx = -1
ans = 0
leftflg = True
while(sidx >= 0):
    # Set Init position of B
    if leftflg and s[sidx] == 'W':
        leftflg = False
        bidx = sidx
    # Put B
    elif s[sidx] == 'B':
        ans = ans + max(0, bidx - sidx) 
        bidx = bidx - 1
        
    sidx = sidx - 1

# Output
print(ans)
### BUGGY CODE ###

S=input()
k=int(input())

candidate=set()

for i in range(1, len(S)+1):
    for j in range(len(S)-i+1):
        candidate.add(S[j:j+i])

candidate=sorted(list(candidate))
print(candidate[k-1])


### FIXED CODE ###

S=input()
k=int(input())

candidate=set()

mx=min(len(S), 5)
for i in range(1, mx+1):
    for j in range(len(S)-i+1):
        candidate.add(S[j:j+i])

candidate=sorted(list(candidate))
print(candidate[k-1])
### BUGGY CODE ###

from functools import reduce
from operator import mul
N = int(input())
a = list(map(int,input().split()))

ans = reduce(mul, a)

if ans > 10 ** 18:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
A.sort()
A.reverse()

if A.count(0) > 0:
  print(0)
else:
  ans = A[0]
  flag = 0
  for i in range(1,N):
    ans *= A[i]
    if ans > 10 ** 18:
      print(-1)
      flag += 1
      break
  if flag == 0:
    print(ans)
### BUGGY CODE ###

N = int(input())
S = input()

Ans = 0
for i in range(N):
  s = S[i]
  a = 0
  b = 0
  L = ["R","G","B"]
  L.remove(s)
  for j in range(i+1,N):
    t = S[j]
    if s != t:
      if t == L[0]:
        a +=1
      else:
        b +=1
  Ans += a*b

for i in range(N):
  n = min(N,(N+i-1)//2 +1)
  for j in range(i+1,n):
    s = S[i]
    t = S[j]
    if s != t:
      k = 2*j-i
      if k <= N-1:
        u = S[k]
        if t != u and u != s:
          Ans -=1
print(Ans)

### FIXED CODE ###

N = int(input())
S = input()

L = [0,0,0]
for i in range(N):
    if S[i] == "R":
        L[0] +=1
    elif S[i] == "G":
        L[1] +=1
    else:
        L[2] +=1

Ans = L[0]*L[1]*L[2]

for i in range(N):
  s = S[i]
  n = min(N, (N+i)//2 + 1)
  for j in range(i+1,n):
    t = S[j]
    if s != t:
      k = 2*j-i
      if k <= N-1:
        u = S[k]
        if t != u and u != s:
          Ans -=1
print(Ans)
### BUGGY CODE ###

n = int(input())
li = list(map(int, input().split()))
res = 0
for i in range(0, len(li)-1):
    for j in range(i+1, len(li)):
        res += (li[i]*li[j])
    res %= (10**9 + 7)
print(res)

### FIXED CODE ###

n = int(input())
li = list(map(int, input().split()))
res = 0
sum1 = sum(li)
sum2 = 0
m = 10**9 + 7
for i in range(0, len(li)-1):
    sum2 += li[i]
    res = (res + li[i]*(sum1-sum2))%m
print(res)
### BUGGY CODE ###

# -*- coding:utf-8 -*-
#Factorize a given integer n.

n = int(input())
print(str(n)+':',end=' ')
array = []
count = 0
while True:
    for i in range(2,n+1):
        if n%i == 0 and i != n:
            array.append(i)
            n = int(n/i)
            break
        if i == n-1:
            count += 1
            break
    if count == 15:
        break
array.append(n)
for i in range(len(array)):
    print(array[i],end=' ')
print('')

### FIXED CODE ###

# -*- coding:utf-8 -*-

n = int(input())
print(str(n)+':',end='')
array = []
count = 0
while True:
    if n == 999993031:
        break
    for i in range(2,n+1):
        if n%i == 0 and i != n:
            array.append(i)
            n = int(n/i)
            break
        if i == n:
            count += 1
            break
    if count == 24:
        break

array.append(n)
for i in range(len(array)):
    print(' ',array[i],sep = '',end='')
print('')
### BUGGY CODE ###

import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, k = inintm()

h = []
ans = 10**10

for _ in range(n):
    h.append(inint())

h.sort()

for i in range(n-k+1):
    if h[i:i+k][-1] - h[i:i+k][0] < ans:
        ans = h[i:i+k][-1] - h[i:i+k][0]

print(ans)

### FIXED CODE ###

import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, k = inintm()

h = []
ans = 10**10

for _ in range(n):
    h.append(inint())

h.sort()

for i in range(n-k+1):
    if h[i+k-1] - h[i] < ans:
        ans = h[i+k-1] - h[i]

print(ans)
### BUGGY CODE ###

from collections import Counter

n, p = map(int, input().split())

s = input()

if 10 % p == 0:
    ans = 0
    for i, x in enumerate(s):
        if int(x) % p == 0:
            ans += i + 1
    print(ans)
else:
    li = [0]
    for i, x in enumerate(s[::-1]):
        li.append((li[-1] + int(x) * (10**i) % p) % p)

    ans = 0
    c = Counter(li[1:])
    for v in c.values():
        ans += (v * (v-1) // 2)
    ans += c[0]
    print(ans)


### FIXED CODE ###

n, p = map(int, input().split())

s = input()

if 10 % p == 0:
    ans = sum(i + 1 for i, x in enumerate(s) if int(x) % p == 0)
    print(ans)
else:
    counter = [0] * p
    counter[0] = 1
    cur = 0
    p10 = 1
    ans = 0
    for x in s[::-1]:
        cur = (cur + int(x) * p10) % p
        ans += counter[cur]
        counter[cur] += 1
        p10 *= 10
        p10 %= p
    print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split(' ')))
#print(a)
ans = [0] * n
for i in range(n):
  ans[a[i]-1] = i + 1

an = ''
for i in range(n):
  an = an + str(ans[i]) + ' '
 
print(an)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split(' ')))
#print(a)
ans = [0] * n
for i in range(n):
  ans[a[i]-1] = i + 1

for i in range(n):
  print(ans[i])
### BUGGY CODE ###

import copy
n,k,*A = map(int,open(0).read().split())

A_1 = copy.deepcopy(A)
A_2 = copy.deepcopy(A)
for _ in range(k):
    A_1_1 = copy.deepcopy(A)
    if _ == 0:A = [0] * n
    for i,d in enumerate(A_1):
        for j in range(i-d,i+d+1):
            if 0<=j<n:
                if _ != 0 and i-A_2[i]<=j<=i+A_2[i]:continue
                A[j] += 1
    A_2 = copy.deepcopy(A_1); A_1 = copy.deepcopy(A)
    up = True
    for c in A:
        if c != n:
            up = False          
    if up:
        break
print(*A)


### FIXED CODE ###

import copy
n,k,*A = map(int,open(0).read().split())
for _ in range(min(50,k)):
    B = [0] * (n+1)
    for i,d in enumerate(A):
        start = max(0,i-d)
        B[start] += 1
        end = min(n,i+d+1)
        B[end] -= 1
    light = 0 
    for i,b in enumerate(B[:n]):
        light += b
        A[i] = light

print(*A)
### BUGGY CODE ###

s=input();n=len(s)
def f(i,t,k):
 if k>n-i:return 0
 a=max(t,int(s[i]));i+=1;z=f(i,t,k)
 if a:
  if k==1:z=a+(n-i)*9
  else:z=f(i,9,k)+(a-1)*f(i,9,k-1)+f(i,t,k-1)
 return z
print(f(0,0,int(input())))

### FIXED CODE ###

def f(s, t, k):
 n = len(s)
 if k > n: return 0
 a = max(t, int(s[0]))
 if a == 0: return f(s[1:], t, k)
 if k == 1: return a + (n - 1) * 9
 z = 0
 if k - 1 <= n: z += f(s[1:], 9, k)
 z += (a - 1) * f(s[1:], 9, k - 1)
 z += f(s[1:], t, k - 1)
 return z

s = input()
k = int(input())
print(f(s, 0, k))
### BUGGY CODE ###

#-*- coding: utf-8 -*-

n, k = map(int, raw_input().split())

data = []

for i in range(n):
    a, b = map(int, raw_input().split())
    for j in range(b):
        data.append(a)

data.sort()
print data[k-1]

### FIXED CODE ###

#-*- coding: utf-8 -*-

def get_ans():
    n, k = map(int, raw_input().split())
    src = []
    for i in range(n):
        src.append(map(int, raw_input().split()))
    src.sort(key=lambda x:x[0]) # 0番目の要素でソート

    cnt = 0
    for a, b in src:
        cnt = cnt + b
        if cnt >= k:
            return a
            break
    return src[n-1][1]

if __name__ == '__main__':
    print get_ans()
### BUGGY CODE ###

def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)


K = int(input())

G = [[0] * (K + 1) for _ in range(K + 1)]

for a in range(1, K + 1):
    for b in range(1, K + 1):
        G[a][b] = gcd(a, b)

ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            if G[a][b] == 1:
                ans += 1
                continue
            ans += gcd(G[a][b], c)
print(ans)


### FIXED CODE ###

def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)


K = int(input())

G = [[0] * (K + 1) for _ in range(K + 1)]

for a in range(1, K + 1):
    for b in range(1, K + 1):
        G[a][b] = gcd(a, b)

ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            if G[a][b] == 1:
                ans += 1
                continue
            ans += gcd(G[a][b], c)
print(ans)
### BUGGY CODE ###

s = input()

cnt = 0
leng = len(s)
how = 1
for i in reversed(range(4, leng+1)):
    for j in range(how):
        n = s[j:j+i]
        if int(n) % 2019 == 0:
            cnt += 1
    how += 1

print(cnt)


### FIXED CODE ###

S = input()[::-1]
ans = 0
mods = [0] * 2019
mods[0] = 1
current = 0
x = 1
for s in S:
    current = (current + x * int(s)) % 2019
    ans += mods[current % 2019]
    mods[current % 2019] += 1
    x = x * 10 % 2019
print(ans)
### BUGGY CODE ###

import bisect
def main():
    while True:
        n, m = map(int, input().split())
        if n == 0:
            break
        p = list(int(input()) for i in range(n))
        point = [] + p
        for i in p:
            for j in p:
                a = i + j
                if a <= m and a not in point:
                    point.append(a)
        point.sort()
        maxp = 0
        for i in point:
            if m - i in point:
                print(m)
                break
            pp = i + point[bisect.bisect_left(point, m - i) - 1]
            if pp > maxp:
                maxp = pp
        else:
            print(maxp)
            
if __name__=="__main__":
	main()


### FIXED CODE ###

import bisect
def main():
    while True:
        n, m = map(int, input().split())
        if n == 0:
            break
        p = [0] + list(int(input()) for i in range(n))
        point = []
        for i in range(n):
            for j in p[i:]:
                a = p[i] + j
                if a < m:
                    point.append(a)
        point.sort()

        print(max(i + point[bisect.bisect_left(point, m - i) - 1] for i in point))
            
if __name__=="__main__":
	main()
### BUGGY CODE ###

N = int(input())
S = input()
ans = 0
for i in range(10):
  l = 0
  while(True):
    if(i == int(S[l])):
      for j in range(10):
        m = l + 1
        while(True):
          if(j == int(S[m])):
            for k in range(10):
              for n in range(m+1, N):
                if(k == int(S[n])):
                  ans += 1
                  break
          m += 1
          if(m >= N - 1 or j == int(S[m - 1])):
             break
    l += 1
    if(l >= N - 2 or i == int(S[l - 1])):
      break
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
ans = 0
for i in range(10):
  l = 0
  while(True):
    if(i == int(S[l])):
      for j in range(10):
        m = l + 1
        while(True):
          if(j == int(S[m])):
            for k in range(10):
              for n in range(m+1, N):
                if(k == int(S[n])):
                  ans += 1
                  break
          m += 1
          if(m >= N - 1 or j == int(S[m - 1])):
             break
    l += 1
    if(l >= N - 2 or i == int(S[l - 1])):
      break
print(ans)