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

s = input()
n = len(s)
cnt = 0
for i in range(n-2):
    for j in range(i+3, n+1):
        if int(s[i:j]) % 2019 == 0:
            cnt += 1

print(cnt)

### FIXED CODE ###

s = input()[::-1]
 
sum_of_digits = 0
 
cnts = [0] * 2019
 
cnts[0] = 1
 
d = 1
 
for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    d %= 2019
    cnts[sum_of_digits] += 1
 
ans = 0

for cnt in cnts:
    ans += cnt * (cnt - 1) // 2
 
print(ans)
### BUGGY CODE ###

import sys
N = int(input())
A = list(map(int, input().split()))
for i in range(N-1):
    for j in range(i+1,N):  
        if A[i] == A[j]:
            print("NO")
            sys.exit()
else:
    print("YES")
            

### FIXED CODE ###

import sys
N = int(input())
A = list(map(int, input().split()))
A2 = sorted(A)
for i in range(N-1): 
        if A2[i] == A2[i+1]: 
            print("NO")
            sys.exit()
else:
    print("YES")
### BUGGY CODE ###

N = int(input())
XL = [list(map(int, input().split())) for _ in range(N)]

XL = sorted(XL, key=lambda x: x[0]+x[1])

ans = [0]
for i in range(1, N):
    can_put = True
    for j in ans:
        # ぶつかった場合
        if XL[i][0] - XL[i][1] < XL[j][0] + XL[j][1] and XL[j][0] - XL[j][1] < XL[i][0] + XL[i][1]:
            can_put = False
    if can_put:
        ans.append(i)

print(len(ans))

### FIXED CODE ###

N = int(input())
XL = [list(map(int, input().split())) for _ in range(N)]

XL = sorted(XL, key=lambda x: x[0]+x[1])

ans = 1
right = XL[0][0] + XL[0][1]

for i in range(1, N):
    if right <= XL[i][0] - XL[i][1]:
        right = XL[i][0] + XL[i][1]
        ans += 1

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

from collections import deque
def main():
    S = input()
    S = deque([c for c in S])
    Q = int(input())
    rvCt = 0
    for _ in range(Q):
        query = input().split()
        if query[0] == '1':
            rvCt += 1
        else:
            if rvCt % 2 == 1:
                S.reverse()
            rvCt = 0
            if query[1] == '1':
                S.appendleft(query[2])
            else:
                S.append(query[2])

    if rvCt % 2 == 1:
        S.reverse()
    
    print(''.join(S))

main()

### FIXED CODE ###

from collections import deque
def main():
    S = input()
    S = deque([c for c in S])
    Q = int(input())
    rvCt = 0

    for _ in range(Q):
        query = input().split()
        if query[0] == '1':
            rvCt += 1
        else:
            doReverse = False
            if rvCt % 2 == 1:
                doReverse = True

            if query[1] == '1':
                if doReverse:
                    S.append(query[2])
                else:
                    S.appendleft(query[2])
            else:
                if doReverse:
                    S.appendleft(query[2])
                else:
                    S.append(query[2])

    if rvCt % 2 == 1:
        S.reverse()
    
    print(''.join(S))

main()
### BUGGY CODE ###

#ABC142D
import math
import fractions
A,B = map(int,input().split())

g = fractions.gcd(A,B)

cnt = 0
first = True

for i in range(2,g+1):
    while g % i == 0:
        g //= i
        #print(g,i)
        if first:
            cnt += 1
            first = False

        if g < i:
            break

    first = True
    if g < i:
        break


print(cnt+1)


### FIXED CODE ###

#ABC142D
import math
import fractions
A,B = map(int,input().split())

g = fractions.gcd(A,B)

cnt = 0
first = True

for i in range(2,int(math.sqrt(g))+1):
    while g%i == 0:
        g //= i
        if first:
            cnt += 1
            first = False

    first = True

if g != 1:
    cnt += 1

print(cnt+1)
### BUGGY CODE ###

import collections


def comb(n):
    return n * (n-1)/2


s = input()
ans = 0
lst_mod = [0]*2019  # O(N)で回した連続値のmod(2019)の値
lst_mod[0] += 1
for i in range(len(s)):
    lst_mod[int(s[i:]) % 2019] += 1
for mod in lst_mod:
    ans += comb(mod)
print(int(ans))


### FIXED CODE ###

import collections


def comb(n):
    return n * (n-1)/2


s = input()
ans = 0
lst_mod = [0]*2019  # O(N)で回した連続値のmod(2019)の値
lst_mod[0] += 1
num, dim = 0, 1
for char in reversed(s):
    num += int(char)*dim
    num %= 2019
    dim *= 10
    dim %= 2019  # サイズを大きくしたくないからmod(2019)を使う
    lst_mod[num] += 1

for mod in lst_mod:
    ans += comb(mod)
print(int(ans))
### BUGGY CODE ###

def main():
    from fractions import gcd
    import sys
    n=int(input())
    a = tuple(map(int, input().split()))
    ans = 1

    mmm=10**9+7
    for i in a:
        ans = ans *i // gcd(ans, i)

    result=0
    for item in a:
      result+=ans//item

    print(result%mmm)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from fractions import gcd
    import sys
    n=int(input())
    a = tuple(map(int, input().split()))
    ans = 1

    mmm=10**9+7
    for i in a:
        ans = ans *i // gcd(ans, i)

    result=0
    for item in a:
      result+=ans//item

    print(result%mmm)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

# coding: utf-8
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import lil_matrix
import numpy

N,M,L=map(int, raw_input().split())
RG=lil_matrix((N,N))

for i in range(M):
    f,t,c = map(int, raw_input().split())
    RG[(f-1,t-1)] = c
    RG[(t-1,f-1)] = c

Rd = floyd_warshall(RG.tocsr())

FG=lil_matrix((N,N))
for i in range(N):
    for j in range(i+1, N):
        if Rd[i][j] <= L:
            FG[(i,j)] = 1
            FG[(j,i)] = 1

Fd = floyd_warshall(FG.tocsr())

Q=int(raw_input())
for i in range(Q):
    s, t = map(int, raw_input().split())
    v = Fd[s-1][t-1]
    if s == t:
        print (str(0))
    elif v == float('inf'):
        print (str(-1))
    else:
        print (str(int(v-1)))


### FIXED CODE ###

# coding: utf-8
from scipy.sparse.csgraph import floyd_warshall

N,M,L=map(int, input().split())
RG=[[0 for i in range(N)] for j in range(N)]

for i in range(M):
    f,t,c = map(int, input().split())
    if c <= L:
        RG[f-1][t-1] = c
        RG[t-1][f-1] = c

Rd = floyd_warshall(RG, directed=False)

FG=[[0 for i in range(N)] for j in range(N)]
for i in range(N):
    for j in range(i+1, N):
        if Rd[i][j] <= L:
            FG[i][j] = 1
            FG[j][i] = 1

Fd = floyd_warshall(FG, directed=False)

Q=int(input())
for i in range(Q):
    s, t = map(int, input().split())
    v = Fd[s-1][t-1]
    if s == t:
        print (str(0))
    if v == float('inf'):
        print (str(-1))
    else:
        print (str(int(v-1)))
### BUGGY CODE ###

R,G,B,N = map(int,input().split())
count = 0
for i in range(N+1):
    for j in range(N+1):
        tmp = N-(R*i)-(G*j)
        if tmp >= 0 and tmp % B == 0:
            count += 1
print(count)


### FIXED CODE ###

R,G,B,N = map(int,input().split())
count = 0
for i in range(N+1):
    for j in range(N+1):
        tmp = N-(R*i)-(G*j)
        if tmp >= 0 and tmp % B == 0:
            count += 1
print(count)
### BUGGY CODE ###

n=input()
num = list(map(int, input().split()))

ans = 1
for i in num:
  ans *= i
if ans > 1000000000000000000:
  ans = -1
print(ans)

### FIXED CODE ###

n=input()
num = list(map(int, input().split()))

num.sort()

ans = 1
for i in num:
  ans *= i
  if ans > 1000000000000000000:
    print(-1)
    exit()
  
if ans > 1000000000000000000:
  ans = -1
print(ans)
### BUGGY CODE ###

n = int(input())
a_list = list(map(int, input().split()))
ans = 0
m = 10 ** 9 + 7

for i in range(n):
    for j in range(i + 1, n):
        ans += a_list[i] * a_list[j]
        ans %= m

print(ans)


### FIXED CODE ###

n = int(input())
a_list = list(map(int, input().split()))
sum_a = sum(a_list)
ans = 0
m = 10 ** 9 + 7

for i in range(n):
    sum_a -= a_list[i]
    ans += a_list[i] * sum_a
    ans %= m

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

def main():
    n= int(input())
    slis = list(input())
    total = 0
    lis_R = [n for n, v in enumerate(slis) if v == "R"]
    lis_G = [n for n, v in enumerate(slis) if v == "G"]
    lis_B = [n for n, v in enumerate(slis) if v == "B"]

    lenR = len(lis_R)
    lenG = len(lis_G)
    lenB = len(lis_B)
    total += lenR * lenG * lenB

    if lenB <= lenG <= lenR:
        for i in lis_R:
            for j in lis_G:
                for k in lis_B:
                    if abs(i-j) == abs(j-k) or abs(i-k)==abs(j-k) or abs(k-i)==abs(j-i):
                        total -= 1

    elif lenB <= lenR <= lenG:
        for i in lis_G:
            for j in lis_R:
                for k in lis_B:
                    if abs(i-j) == abs(j-k) or abs(i-k)==abs(j-k) or abs(k-i)==abs(j-i):
                        total -= 1

    elif lenG <= lenB <= lenR:
        for i in lis_R:
            for j in lis_B:
                for k in lis_G:
                    if abs(i-j) == abs(j-k) or abs(i-k)==abs(j-k) or abs(k-i)==abs(j-i):
                        total -= 1
    elif lenG <= lenR <= lenB:
        for i in lis_B:
            for j in lis_R:
                for k in lis_G:
                    if abs(i-j) == abs(j-k) or abs(i-k)==abs(j-k) or abs(k-i)==abs(j-i):
                        total -= 1
    elif lenR <= lenB <= lenG:
        for i in lis_G:
            for j in lis_B:
                for k in lis_R:
                    if abs(i-j) == abs(j-k) or abs(i-k)==abs(j-k) or abs(k-i)==abs(j-i):
                        total -= 1
    elif lenR <= lenG <= lenB:
        for i in lis_B:
            for j in lis_G:
                for k in lis_R:
                    if abs(i-j) == abs(j-k) or abs(i-k)==abs(j-k) or abs(k-i)==abs(j-i):
                        total -= 1
    print(total)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    import re
    n = int(input())
    s = input()
    rindex = set()
    gindex = set()
    bindex = set()
    for i in range(n):
        if s[i] == "R":
            rindex.add(i)
        elif s[i] == "G":
            gindex.add(i)
        else:
            bindex.add(i)
    ans = len(rindex) * len(gindex) * len(bindex)

    for r in rindex:
        for g in gindex:
            if r > g:
                gap = r - g
                b1 = r + gap
                b2 = g - gap
                b3 = g + (gap/2)

            elif r < g:
                gap = g - r
                b1 = g + gap
                b2 = r - gap
                b3 = r + (gap/2)
            if b1 in bindex:
                ans -= 1
            if b2 in bindex:
                ans -= 1  
            if b3 in bindex:
                ans -= 1  
    print(ans)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

l,r=map(int,input().split())
ans = 2019
for i in range(l,r):
	for j in range(i+1,r+1):
		ans = min(ans,i*j%2019)
print(ans)



### FIXED CODE ###

l,r=map(int,input().split())
ans = 2019
for i in range(l,min(r,l+2030)):
	for j in range(i+1,min(r+1,i+2030)):
		ans = min(ans,i*j%2019)
print(ans)
### BUGGY CODE ###

def main():
    N = int(input())
    A = [0] * N
    B = [0] * N
    C = []
    for i in range(N):
        A[i], B[i] = map(int, input().split())
        C.append([A+B, i])

    C.sort(reverse=True)
    ans = 0
    for i, c in enumerate(C):
        if i % 2 == 0:
            ans += A[c[1]]
        else:
            ans -= B[c[1]]

    print(ans) 

    
    



if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N = int(input())
    A = [0] * N
    B = [0] * N
    C = [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
        C[i] = A[i] + B[i]

    C.sort(reverse=True)
    ans = -sum(B)
    for i, c in enumerate(C):
        if i % 2 == 0:
            ans += C[i]
    
    print(ans) 

    
    



if __name__ == "__main__":
    main()
### BUGGY CODE ###

n, k, q = map(int, input().split())
a= [int(input()) for i in range(q)]

for i in range(n):
        if q - a.count(i+1) < k:
                print('Yes')
        else:
                print('No')


### FIXED CODE ###

import collections
n, k, q = map(int, input().split())
a= [int(input()) for i in range(q)]
c=collections.Counter(a)

for i in range(n):
        if q - c[i+1] < k:
                print('Yes')
        else:
                print('No')
### BUGGY CODE ###


x = int(input())
power = 1
for i in range(1, x+1):
    power *= i
   # print(power)

print(power%(pow(10, 9)+7))


### FIXED CODE ###


import math
#import itertools
#import statistics
#import numpy as np
#import collections
n = int(input())
#k, s = list(map(int, input().split()))
#a = list(map(int, input().split()))
print(math.factorial(n)%(pow(10, 9)+7))
### BUGGY CODE ###

N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(M)]


class UnionFind():
    def __init__(self,size):
        self.table = [-1 for _ in range(size)]

    def find(self,x):
        while self.table[x] >= 0:
            x = self.table[x]
        return x

    def union(self,x,y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 == s2:
            return
        if self.table[s1] >= self.table[s2]:
            self.table[s1] += self.table[s2]
            self.table[s2] = s1
        else:
            self.table[s2] += self.table[s1]
            self.table[s1] = s2


def func1(x, y):
    global uf
    px = uf.find(x)
    py = uf.find(y)
    if px == py:
        return 0
    r = uf.table[px] * uf.table[py]
    uf.union(px, py)
    return r


def main():
    ans = [0] * (M - 1)
    p = 0
    for q in range(M - 1, 0, -1):
        p += func1(A[q][0] - 1, A[q][1] -1)
        ans[q - 1] = p

    nall = N * (N - 1) // 2
    for a in ans:
        print(nall - a)
    print(nall)


uf = UnionFind(N)
main()

### FIXED CODE ###

N, M = map(int, input().split())
ab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]


class UnionFind:
    def __init__(self,size):
        self.rank = [-1 for _ in range(size)]
        self.number = [1 for _ in range(size)]

    def find(self,x):
        while self.rank[x] >= 0:
            x = self.rank[x]
        return x

    def union(self,x,y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 == s2:
            return
        if self.rank[s1] == self.rank[s2]:
            self.rank[s1] -= 1
            self.rank[s2] = s1
            self.number[s1] += self.number[s2]
        elif self.rank[s1] < self.rank[s2]:
            self.rank[s2] = s1
            self.number[s1] += self.number[s2]
        else:
            self.rank[s1] = s2
            self.number[s2] += self.number[s1]


def main():
    uf = UnionFind(N)
    p = N * (N - 1) // 2
    ans = [p]
    for x, y in reversed(ab):
        px = uf.find(x)
        py = uf.find(y)
        if px != py:
            p -= uf.number[px] * uf.number[py]
            uf.union(px, py)
        ans.append(p)

    for a in reversed(ans[:-1]):
        print(a)


main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)
n,q=map(int,input().split())
g=[[]for i in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

lis = [0 for i in range(n)]
for i in range(q):
    p,x=map(int,input().split())
    lis[p-1]+=x

def dfs(i,j,k):
    nex=g[i]
    lis[i]=k
    for d in nex:
        if d==j: continue
        #print(d)
        nk=k+lis[d]
        dfs(d,i,nk)

dfs(0,-1,lis[0])
print(*lis)


### FIXED CODE ###

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

lis = [0 for i in range(n)]
for i in range(q):
    p,x=map(int,input().split())
    lis[p-1]+=x

def dfs(i,j):
    nex=g[i]
    for d in nex:
        if d==j: continue
        #print(d)
        lis[d]+=lis[i]
        dfs(d,i)

dfs(0,-1)
print(*lis)
### BUGGY CODE ###

n,k = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]


def kitaichi(num):
    return (sum(range(num+1)) / num)

t = [0] * n
for i in range(n):
    t[i] = kitaichi(p[i])

ans = 0
for i in range(n-k+1):
    tmp = sum([t[x] for x in range(i, i+k)])
    ans = max(ans,tmp)

print(ans)

### FIXED CODE ###

n,k = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]


t = [0] * (n+k+1)
for i in range(n):
    t[i+1] = t[i] + p[i]

ans = 0
for i in range(n):
    ans = max(ans, t[i+k]-t[i])
print((ans+k)/2)
### BUGGY CODE ###

N=int(input())
A=list(map(int, input().split()))
MOD=7+10**9
ans=0
for i in range(len(A)-1):
    for j in range(i+1,len(A)):
        ai= A[i] % MOD
        aj= A[j] % MOD
        ans = ans +ai*aj % MOD
print(ans%MOD)

### FIXED CODE ###

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

MOD=7+10**9
SUM=sum(A)
ans=0

for i in range(N-1):
    SUM-=A[i]
    ans += A[i]*SUM %MOD
print(ans %MOD)
### BUGGY CODE ###

n = int(input())
A = input().split()
b = []
for i,a in enumerate(A):
    if i%2==0:
        b.insert(0,a)
    else:
        b.append(a)
print(' '.join(reversed(b)) if n%2==0 else ' '.join(b))

### FIXED CODE ###

n = int(input())
A = input().split()
if n%2==0:
    print(' '.join(A[1::2][::-1]),end=' ')
    print(' '.join(A[::2]))
else:
    print(' '.join(A[::2][::-1]),end=' ')
    print(' '.join(A[1::2]))
### BUGGY CODE ###

N = int(input())
S = input()
exc = 0

for i in range(N - 2):
    for j in range(1, N - 1):
        d = j - i
        if d <= 0 or d + j > N - 1 or S[i] == S[j]:
            continue
        k = d + j
        if S[k] != S[i] and S[k] != S[j]:
            exc += 1

ans = S.count("R") * S.count("G") * S.count("B") - exc
print(ans)


### FIXED CODE ###

N = int(input())
S = [s for s in input()]
ans = S.count("R") * S.count("G") * S.count("B")

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = j + (j - i)
        if N - 1 < k:
            continue
        if S[k] != S[i] and S[k] != S[j] and S[i] != S[j]:
            ans -= 1

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

N=int(input())
A=list(map(int,input().split()))
pre=0
for i in range(N-1):
    if A[i]!=pre:
        print(A.count(i+1))
    else:
        print(0)
        pre=A[i]
print(0)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
P=[0]*N
for i in range(N-1):
    P[A[i]-1]+=1
for i in range(N):
    print(P[i])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
import heapq


def main():
    N,K = list(map(int, sys.stdin.readline().split()))
    A_list = list(map(int, sys.stdin.readline().split()))
    

    # hq = [ [ -length of the log cut  , the initial length of log , the number of cut ] ]
    hq = [ [-a,a,0] for a in A_list ]
    heapq.heapify(hq)

    while K:
        _ , len_a, num_cut = heapq.heappop(hq)
        num_cut += 1
        K -= 1

        heapq.heappush(hq, [ -(len_a / (num_cut + 1)) , len_a , num_cut] )
    
    
    len_cut , len_a, num_cut = heapq.heappop(hq)
    len_cut = -(len_cut // 1)  # round up (len_cut is negative number)
    print( int(len_cut) )


if __name__ == "__main__":
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from decimal import Decimal, ROUND_HALF_UP


def main():
    N,K = list(map(int, sys.stdin.readline().split()))
    A_list = list(map(int, sys.stdin.readline().split()))


    def check(length :int) -> bool:
        cnt = 0

        for a in A_list:
            if a >= length:
                quotient = a / length
                divide = -(-quotient // 1)  # round up
                cnt += (divide - 1)
        
        return (True if cnt <= K else False)


    L = 0.1            # the minimum length
    R = max(A_list)  # the maximum length

    while (R - L) > 0.01:
        M = L + (R - L) / 2

        if check(M):
            R = M
        else:
            L = M
    
    
    ans = float( Decimal(str(M)).quantize(Decimal('1E-1'), rounding=ROUND_HALF_UP) )
    ans = -(-ans // 1)  # round up
    print( int(ans) )


if __name__ == "__main__":
    main()
### BUGGY CODE ###

import math
k = int(input())

ans = 0
for a in range(1, k+1):
  for b in range(1, k+1):
   for c in range(1, k+1):
     gcd_ab = math.gcd(a,b)
     ans += math.gcd(gcd_ab, c)

print(ans)


### FIXED CODE ###

import math
k = int(input())

ans = 0
for a in range(1, k+1):
  for b in range(1, k+1):
   gcd_ab = math.gcd(a,b)
   for c in range(1, k+1):
     ans += math.gcd(gcd_ab, c)

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

from collections import  deque
h,w = map(int,input().split())
mp = []
for _ in range(h):
    row = list(input())
    mp.append(row)

q = deque()
dist = [[-1] * w for i in range(h)]

for col in range(h):
    for row in range(w):
        if mp[col][row] == '#':
            q.append((col,row))
            dist[col][row] = 0
ans = 0
while len(q) != 0:
    now = q.popleft()
    for x,y in ((1,0), (0,1), (-1,0), (0,-1)):
        next_x = now[0] + x
        next_y = now[1] + y
        if 0 <= next_x < h and 0 <= next_y < w :
            if mp[next_x][next_y] == '.' and dist[next_x][next_y] < 0:
                q.append((next_x, next_y))
                dist[next_x][next_y] = dist[now[0]][now[1]] + 1
                ans = max(ans,dist[next_x][next_y])
print(ans)


### FIXED CODE ###

from collections import  deque
h,w = map(int,input().split())
mp = []
for _ in range(h):
    row = list(input())
    mp.append(row)

q = deque()
dist = [[-1] * w for _ in range(h)]

for col in range(h):
    for row in range(w):
        if mp[col][row] == '#':
            q.append((col,row))
            dist[col][row] = 0
ans = 0
while q:
    now_x,now_y = q.popleft()
    ans = dist[now_x][now_y]
    for x,y in ((1,0), (0,1), (-1,0), (0,-1)):
        next_x = now_x + x
        next_y = now_y + y
        if 0 <= next_x < h and 0 <= next_y < w :
            if dist[next_x][next_y] < 0:
                q.append((next_x, next_y))
                dist[next_x][next_y] = ans + 1

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

import copy
from itertools import combinations
N=int(input())
S=list(input()[0] for _ in range(N))
cS=copy.deepcopy(S)
ans=0
for i in cS:
    if i not in ['M', 'A', 'R', 'C', 'H']:
        S.remove(i)
P=list(combinations(S,3))
for i in P:
    if len(set(i))==3:
        ans+=1
print(ans)

### FIXED CODE ###

N=int(input())
S=list(input()[0] for _ in range(N))
m=S.count('M')
a=S.count('A')
r=S.count('R')
c=S.count('C')
h=S.count('H')
print(m*a*r+m*a*c+m*a*h
      +m*r*c+m*r*h
      +m*c*h
      +a*r*c+a*r*h
      +a*c*h
      +r*c*h)
### BUGGY CODE ###

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

    return r, g, b, n


def main():
    r, g, b, n = input_from_console()
    counter = 0
    r, g, b = sorted([r, g, b], reverse=True)
    # print(r,g,b)
    for i1 in reversed(range(int(n / r) + 1)):
        n1 = n - r * i1
        for i2 in reversed(range(int(n1 / g) + 1)):
            n2 = n1 - g * i2
            # print(n2, i1, i2)
            if r * i1 + g * i2 + b * (n - i1 - i2) < n2:
                continue
            for i3 in reversed(range(int(n2 / b) + 1)):
                # print(i1, i2, i3, r * i1 + g * i2 + b * i3)
                n_new = r * i1 + g * i2 + b * i3
                if r * i1 + g * i2 + b * i3 == n:
                    counter += 1
                    break
                elif n_new < n:
                    break

    print(counter)


if __name__ == "__main__":
    main()

### FIXED CODE ###


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

    return r, g, b, n


def main():
    r, g, b, n = input_from_console()
    counter = 0
    r, g, b = sorted([r, g, b], reverse=True)
    for i1 in reversed(range(int(n / r) + 1)):
        n1 = n - r * i1
        for i2 in reversed(range(int(n1 / g) + 1)):
            n2 = n1 - g * i2
            if n2 % b == 0:
                counter += 1
    print(counter)


if __name__ == "__main__":
    main()