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

import math

n = int(input())
s = input()

if s[0] == 'W' or s[-1] == 'W':
    print(0)
else:    
    s_lr = 'L'
    for i in range(len(s)-1):
        if s[i+1] == s[i]:
            if s_lr[-1] == 'L':
                s_lr += 'R'
            else:
                s_lr += 'L'
        else:
            if s_lr[-1] == 'L':
                s_lr += 'L'
            else:
                s_lr += 'R'    
    l_cnt = 0
    r_cnt = 0
    lst = []
    for i in s_lr:
        if i == 'L':
            l_cnt += 1
            lst.append(0)
        else:
            if l_cnt - r_cnt <= 0:
                print(0)
                break
            else:
                lst.append(l_cnt - r_cnt)
            r_cnt += 1
    else:
        if l_cnt != r_cnt:
            print(0)
        else:
            res = 1
            for i in lst:
                if i > 0:
                    res = res * i % (10**9 + 7)
            print(res * math.factorial(n) % (10**9 + 7) )

### FIXED CODE ###

import math

n = int(input())
s = input()

if s[0] == 'W' or s[-1] == 'W':
    print(0)
else:    
    s_lr = 'L'
    for i in range(len(s)-1):
        if s[i+1] == s[i]:
            if s_lr[-1] == 'L':
                s_lr += 'R'
            else:
                s_lr += 'L'
        else:
            if s_lr[-1] == 'L':
                s_lr += 'L'
            else:
                s_lr += 'R'    
    l_cnt = 0
    r_cnt = 0
    lst = []
    for i in s_lr:
        if i == 'L':
            l_cnt += 1
            lst.append(0)
        else:
            if l_cnt - r_cnt <= 0:
                print(0)
                break
            else:
                lst.append(l_cnt - r_cnt)
            r_cnt += 1
    else:
        if l_cnt != r_cnt:
            print(0)
        else:
            res = 1
            for i in lst:
                if i > 0:
                    res = res * i % (10**9 + 7)
            print(res * math.factorial(n) % (10**9 + 7) )
### BUGGY CODE ###

# EDPC A Frog 1
N, K = map(int, input().split())
H = list(map(int,input().split()))

f_inf = float("inf")
cost = [f_inf]*N

cost[0] = 0
cost[1] = abs(H[1]-H[0])

for i in range(2,N):
    for k in range(1,K+1):
        if i - k < 0:
            break
        if cost[i] > cost[i-k]+abs(H[i]-H[i-k]):
            cost[i] = cost[i-k]+abs(H[i]-H[i-k])

print(cost[N-1])

### FIXED CODE ###

# EDPC B Frog 2
N, K = map(int, input().split())
H = list(map(int,input().split()))

cost = [float("inf")]*N
cost[0] = 0
cost[1] = abs(H[1]-H[0])

for i in range(2,N):
    for k in range(1,min(K,i)+1):
        cost[i] = min(cost[i], cost[i-k]+abs(H[i]-H[i-k]))

print(cost[N-1])
### BUGGY CODE ###

import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
from sys import flags
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
x=list(input())
cnt=Counter(x)
x2=int("".join(x),2)
one=cnt["1"]
# print(x)
# print(math.log2(2*10**5))
# print(cnt)
# print(x2,one)
lst=[0]*(2*10**5+10)
# lst[0]=-1
flaglst=[0,0]
if one-1!=0:
    flaglst[0]=x2%(one-1)
flaglst[1]=x2%(one+1)
# print(flaglst)

for i in range(2*10**5):
    now=i+1
    ans=0
    while now:
        cnt2=0
        m=0
        while now>=pow(2,m):
            if now&1<<m:
                cnt2+=1
            m+=1
        now%=cnt2
        ans+=1
    lst[i+1]=ans
# # print(lst[:100])

for i in range(n):
    tmp=0
    if x[i]=="1":
        tmp=flaglst[0]
        if one-1!=0:
            tmp-=pow(2,n-1-i,one-1)
            tmp%=one-1
        else:
            print(0)
            continue
    else:
        tmp=x2%(one+1)
        tmp+=pow(2,n-1-i)
        tmp%=one+1
    # print(tmp,pow(2,n-1-i),one)

    print(lst[tmp]+1)

### FIXED CODE ###

import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
from sys import flags
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
x=list(input())
cnt=Counter(x)
x2=int("".join(x),2)
one=cnt["1"]
# print(x)
# print(math.log2(2*10**5))
# print(cnt)
# print(x2,one)
lst=[0]*(2*10**5+10)
# lst[0]=-1
flaglst=[0,0]
if one-1!=0:
    flaglst[0]=x2%(one-1)
flaglst[1]=x2%(one+1)
# print(flaglst)

for i in range(2*10**5):
    now=i+1
    ans=0
    while now:
        cnt2=0
        m=0
        while now>=pow(2,m):
            if now&1<<m:
                cnt2+=1
            m+=1
        now%=cnt2
        ans+=1
    lst[i+1]=ans
# # print(lst[:100])

for i in range(n):
    tmp=0
    if x[i]=="1":
        tmp=flaglst[0]
        if one-1!=0:
            tmp-=pow(2,n-1-i,one-1)
            tmp%=one-1
        else:
            print(0)
            continue
    else:
        tmp=flaglst[1]
        tmp+=pow(2,n-1-i,one+1)
        tmp%=one+1
    # print(tmp,pow(2,n-1-i),one)

    print(lst[tmp]+1)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import math
MOD = 10**9+7

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

if S[0] == "W" or S[-2] == "W":
    print(0)
    sys.exit()

LR = [0]
for i in range(1, 2*N):
    if LR[i-1] == 0:
        if S[i] == S[i-1]:
            LR.append(1)
        else:
            LR.append(0)
    else:
        if S[i] == S[i-1]:
            LR.append(0)
        else:
            LR.append(1)

if LR.count(0) != N:
    print(0)
    sys.exit()

count0 = 0
ans = 1
for i in range(2*N):
    if LR[i] == 0:
        count0 += 1
    else:
        ans *= count0
        count0 -= 1

print(ans*math.factorial(N)%MOD)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 10**9+7

N = int(input())
S = list(input().rstrip())

if S[0] == "W" or S[-1] == "W":
    print(0)
    sys.exit()

LR = [0 for i in range(2*N)]
count0 = 1
count0_raw = 1
ans = 1
for i in range(1, 2*N):
    if LR[i-1] == 0:
        if S[i] == S[i-1]:
            LR[i] = 1
        else:
            LR[i] = 0
    else:
        if S[i] == S[i-1]:
            LR[i] = 0
        else:
            LR[i] = 1

    if LR[i] == 0:
        count0 += 1
        count0_raw += 1
    else:
        ans *= count0
        ans %= MOD
        count0 -= 1

if count0_raw != N:
    print(0)
    sys.exit()

N_k = 1
for i in range(N):
    N_k *= i+1
    N_k %= MOD

print(ans*N_k%MOD)
### BUGGY CODE ###

from fractions import gcd
n = int(input())
*A, = map(int, input().split())
for _ in range(n-2):
    A = [gcd(A[i-1], A[i]) for i in range(n)]
print(max(A))

### FIXED CODE ###

from fractions import gcd
n = int(input())
*A, = map(int, input().split())
L = [0]*n
R = [0]*n
for i in range(n-1):
    L[i] = gcd(L[i-1], A[i])
    R[n-1-i] = gcd(R[(n-i)%n], A[n-1-i])
B = [gcd(L[i-1], R[(i+1)%n]) for i in range(n)]
print(max(B))
### BUGGY CODE ###

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

def div(n):
    for k in range(2,n+1):
        if n % k == 0:
            return k
    return 1

def pf(n):
    pf=[]
    while n != 1:
        pf.append(div(n))
        n = n // div(n)
    p = list(set(pf))
    return p

"""pc = True
for i in range(N-1):
    ai = pf(A[i])
    li = len(ai)
    for j in range(i+1,N):
        aj = pf(A[j])
        lj = len(aj)
        a = list(set(ai + aj))
        if (li + lj) != len(a):
            pc = False
            break
        """


cp = False
apf =[]
for e in range(N):
    apf.extend(pf(A[e]))
l1 = len(apf)
l2 = len(list(set(apf)))
if l1 == l2:
    cp = True

if cp == False:
    sc = False
    g = functools.reduce(math.gcd, A)
    if g == 1:
        sc = True


if cp == True:
    print('pairwise coprime')
elif sc == True:
    print('setwise coprime')
else:
    print('not coprime')











### FIXED CODE ###

import math
n = int(input())
a = list(map(int,input().split()))

c = [0]*(10**6 + 3)
for i in a:
    c[i] += 1

pairwise = True
for i in range(2,10**6+1):
    if sum(c[::i])>1:
        pairwise = False

g = 0
for i in a:
    g = math.gcd(g,i)
if g == 1:
    setwise = True
else:
    setwise = False

if pairwise == True:
    print("pairwise coprime")
elif setwise == True:
    print("setwise coprime")
else:
    print("not coprime")
### BUGGY CODE ###

K, S = [int(x) for x in input().split()]

ans = 0

for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if x + y + z == S:
                ans += 1

print(ans)

### FIXED CODE ###

K, S = [int(x) for x in input().split()]

ans = 0

for x in range(max(0, S - 2 * K), min(K, S) + 1):
    ans += min(K, S - x) - max(0, S - x - K) + 1

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

import sys
input = sys.stdin.readline
n,m= map(int,input().split())

B = []
C = [0]*n
ans = 0
pna = 0
for i in range(m):
    A = list(map(str,input().split()))
    if A[1]=="AC":
        if A[0] not in B :
            B.append(A[0])
            ans += 1
            pna += C[int(A[0])-1]
    else:
        C[int(A[0])-1] += 1 
print(ans,pna)

### FIXED CODE ###

N,M = [int(x) for x in input().split()]
count = [0]*N
ac = 0
wa = 0
ireta = []
for i in range(M):
    a,b = input().split()
    a = int(a)
    if b == "AC" and count[a-1] == 0:
        count[a-1] = 1
        ac += 1
    elif count[a-1] == 0:
        ireta.append(a)
        wa += 1
for i in range(len(ireta)):
    if count[ireta[i]-1] == 0:
        wa -= 1
print(ac,wa)
### BUGGY CODE ###

# https://atcoder.jp/contests/abc153/tasks/abc153_e


def main():
    h, n = map(int, input().split(" "))
    dp = [float("inf")] * (h + 1)
    dp[0] = 0
    for i in range(n):
        damage, cost = map(int, input().split(" "))
        for total in range(h +1):
            # 現在の蓄積ダメージから、魔法iを使った場合に与えるダメージ
            next_damage = min(total + damage, h)
            dp[next_damage] = min(dp[next_damage], dp[total] + cost)
    print(dp[-1])


if __name__ == '__main__':
    main()


### FIXED CODE ###

# https://atcoder.jp/contests/abc153/tasks/abc153_e


def main():
    h, n = map(int, input().split(" "))
    dp = [float("inf")] * (h + 1)
    dp[0] = 0
    for i in range(n):
        damage, cost = map(int, input().split(" "))
        for total in range(h +1):
            # 現在の蓄積ダメージから、魔法iを使った場合に与えるダメージ
            next_damage = min(total + damage, h)
            dp[next_damage] = min(dp[next_damage], dp[total] + cost)
    print(dp[-1])


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

N = int(input())
S = input()
S = S + "Z"
sum_w = []
sum_e = []

for i in range(N):
  sum_w.append(S[:i].count("W"))

for i in range(N):
  sum_e.append(S[i+1:].count("E"))

#print(sum_e, sum_w)
sumu = [x+y for x, y in zip(sum_w, sum_e)]

print(min(sumu))

### FIXED CODE ###

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

sum_w = [0]
sum_e = [0]

count = 0
for i in range(N-1):
  if S[i] == "W":
    count += 1
  sum_w.append(count)

count = 0
for i in range(N-1,0,-1):
  if S[i] == "E": 
    count += 1
  sum_e.append(count)
sum_e = sum_e[::-1]

#print(len(sum_e), len(sum_w))
sumu = [x+y for x, y in zip(sum_w, sum_e)]

print(min(sumu))
### BUGGY CODE ###

from bisect import bisect_left
n,k = (int(i) for i in input().split())
b = [[int(i)-1 for i in input().split()] for i in range(n-1)]
x,d,ans = [[] for i in range(n)],[[None]*n for i in range(n)],n
for i,j in b:
	x[i].append(j)
	x[j].append(i)
for i in range(n):
	q,v,d[i][i] = [],[1]*n,(0,-1)
	v[i] = 0
	for j in x[i]:
		q.append((j,1,j))
		d[i][j],v[j] = (1,j),0
	while q:
		p = q.pop()
		for j in x[p[0]]:
			if v[j]:
				q.append((j,p[1]+1,p[2]))
				d[i][j],v[j] = (p[1]+1,p[2]),0
if k%2:
	for i in range(n-1):
		a = n
		for j,j2 in d[b[i][0]]:
			if b[i][1]!=j2 and (k-1)//2>=j: a-=1
		for j,j2 in d[b[i][1]]:
			if b[i][0]!=j2 and (k-1)//2>=j: a-=1
		ans = min(a,ans)
else:
	for i in range(n): ans = min(ans,n-bisect_left(sorted(d[i]),(k//2+1,0)))
print(ans)

### FIXED CODE ###

from collections import deque
n,k = (int(i) for i in input().split())
b = [[int(i)-1 for i in input().split()] for i in range(n-1)]
x,d,ans,c = [[] for i in range(n)],[[] for i in range(n)],n,0
for i,j in b:
	x[i].append(j)
	x[j].append(i)
def f(s):
	for i in range(n):
		q,v = deque(),[1]*n
		v[i] = 0
		for j in x[i]:
			q.append((j,1,j))
			d[i].append(j)
			v[j] = 0
		while q:
			p = q.pop()
			if p[1]<s:
				for j in x[p[0]]:
					if v[j]:
						q.append((j,p[1]+1,p[2]))
						d[i].append(p[2])
						v[j] = 0
if k>n//2:
	for i in x: c = max(len(i),c)
if n-c+1<=k: ans = 0
elif k==1: ans = n-2
else:
	f(k//2)
	if k%2:
		for i,j in b: ans = min(ans,n-len(d[i])-len(d[j])+d[i].count(j)+d[j].count(i)-2)
	else:
		for i in range(n): ans = min(ans,n-len(d[i])-1)
print(ans)
### BUGGY CODE ###

import itertools
import collections
n=int(input())
s=[list(map(int, input().split())) for i in range(n)]
ans=[]
x=list(itertools.permutations(s))

if n==1:
    print(n)
else:
    v=[]
    r=[]
    for i in range(len(x)):
        e=[]
        v=[]
        for j in range(n-1):
            a=x[i][j][0]
            b=x[i][j+1][0]
            c=x[i][j][1]
            d=x[i][j+1][1]
            v.append(b-a)
            v.append(d-c) 
        q=[v[i:i+2] for i in range(0,len(v),2)]
        for i in range(len(q)):
            e.append(q.count(q[i]))
        r.append(max(e))
    print(n-max(r))

### FIXED CODE ###

n=int(input())
s=[list(map(int, input().split()))  for i in range(n)]
x=[]
if n==1:
    print(1)
    exit(0)

for i in range(n):
    for j in range(n):
        if i==j:
            continue
        t=(s[i][0]-s[j][0],s[i][1]-s[j][1])
        x.append(t)
        
ans = [x.count(x[i]) for i in range(len(x))]
print(n-max(ans))
### BUGGY CODE ###

a, b = map(int, input().split())
ans = a
if a != b:
    for i in range(a+1, b+1):
        ans = ans ^ i
else:
    ans = a
print(ans)

### FIXED CODE ###

def func(n):
    if n % 2 == 1:
        a = n + 1
    else:
        a = n 
    if a % 4 == 0:
        between = 1
    else:
        between = 0
    if n % 2 == 0:
        ans = between ^ n
    else:
        ans = between
    return ans

n, m = map(int, input().split())
ans = func(n - 1) ^ func(m)
print(ans)
### BUGGY CODE ###

from collections import Counter
def main():
    mod=2019
    S=input().strip()
    l=len(S)
    M=[0]*(l+1)
    p=1
    for i in range(1,l+1):
        x=int(S[l-i])
        M[i]=(M[i-1]+x*p)%mod
        p*=10
    C=Counter(M)
    ans=0
    for _,m in C.items():
        ans+=m*(m-1)//2
    print(ans)
    
if __name__=='__main__':
    main()

### FIXED CODE ###

from collections import Counter
def main():
    mod=2019
    S=input().strip()
    l=len(S)
    M=[0]*(l+1)
    p=1
    for i in range(1,l+1):
        x=int(S[l-i])
        M[i]=(M[i-1]+x*p)%mod
        p*=10
        p%=mod
    C=Counter(M)
    ans=0
    for m in C.values():
        ans+=m*(m-1)//2
    print(ans)
    
if __name__=='__main__':
    main()
### BUGGY CODE ###

N = int(input())
str_lis = []
max_str_lis = []
max_num = 1
for i in range(N):
  A = str(input())
  str_lis.append(A)
  times = str_lis.count(A)
  if times > max_num:
    max_str_lis = []
    max_str_lis.append(A)
    max_num = times
  if times == max_num and not A in max_str_lis:
    max_str_lis.append(A)

a = []
for i in max_str_lis:
  b = []
  for j in range(len(i)):
    b.append(ord(i[j]))
  a.append(b)
  
new_a = sorted(a)
for i in range(len(new_a)):
  for j in range(len(new_a[i])):
    new_a[i][j] = chr(new_a[i][j])
    
for i in new_a:
  print("".join(i))

### FIXED CODE ###

from collections import Counter

N = int(input())

str_lis = [str(input()) for i in range(N)]
c = Counter(str_lis)
a = c.most_common()
num = a[0][1]
b = []
for i in a:
  if i[1] == num:
    b.append(i[0])
    num = i[1]
  else:
    break
    
new_b = sorted(b)
for i in new_b:
  print(i)
### BUGGY CODE ###

n, k = map(int, input().split())
b = k
r = n-k
MOD = 10**9+7

def comb(n, k, MOD):
    return fact[n] * invfact[k] * invfact[n-k] % MOD

lenlist = 4*(10**6)
fact = [1] * lenlist
invfact = [1] * lenlist

for i in range(1, lenlist):
    fact[i] = fact[i-1] * i % MOD

invfact[lenlist - 1] = pow(fact[lenlist - 1], MOD-2, MOD)

for i in range(lenlist-1, 0, -1):
    invfact[i-1] = invfact[i] * i % MOD

for i in range(k):
    if i == 0:
        print(r+1)
        continue
    if i > r:
        print(0)
        continue
    ans = comb(r+1, i+1, MOD)
    ans *= comb(b-1, i, MOD)
    ans %= MOD
    print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
b = k
r = n-k
MOD = 10**9+7

def comb(n, k, MOD):
    return fact[n] * invfact[k] * invfact[n-k] % MOD

lenlist = 4*(10**6)
fact = [1] * lenlist
invfact = [1] * lenlist

for i in range(1, lenlist):
    fact[i] = fact[i-1] * i % MOD

invfact[lenlist - 1] = pow(fact[lenlist - 1], MOD-2, MOD)

for i in range(lenlist-1, 0, -1):
    invfact[i-1] = invfact[i] * i % MOD

for i in range(k):
    if i == 0:
        print(r+1)
        continue
    if i > r:
        print(0)
        continue
    ans = comb(r+1, i+1, MOD)
    ans *= comb(b-1, i, MOD)
    ans %= MOD
    print(ans)
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.readline
    from collections import defaultdict
    N = int(input())
    A = []
    C = defaultdict(int)
    for i in map(int, input().split()):
        if C[i] == 0:
            A.append(i)
        C[i] += 1
    A.sort()
    X = []
    ans = 0
    for a in A:
        for x in X:
            if a % x == 0:
                break
            if 2 * x > a:
                if C[a] == 1:
                    ans += 1
                X.append(a)
                break
        else:
            if C[a] == 1:
                ans += 1
            X.append(a)
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    from collections import Counter
    N = int(input())
    A = sorted(list(map(int, input().split())))
    C = Counter(A)
    dp = [False] * 1100000
    ans = 0
    for a, cnt in C.items():
        if dp[a]:
            continue
        for i in range(2*a, 1100000, a):
            dp[i] = True
        if cnt == 1:
            ans += 1
    print(ans)

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

XY=list(map(int,input().split()))

x=max(XY)
y=min(XY)
x_dy=x%y

ans=0
if x==y:
    ans=x
else:
    for d in range(1,(y+1)//2):
        if y%d==0 and x_dy%d==0:
            ans=d

print(ans)

### FIXED CODE ###

def euclidean_alg(x,y):
    while y:
        x,y=y,x%y
    return x

XY=list(map(int,input().split()))
x=max(XY)
y=min(XY)

print(euclidean_alg(x,y))
### BUGGY CODE ###

# your code goes here
N=int(input())
s=list(input())
a = [0]*N
for i in range(0,N):
	if s[i]=='E':
		for j in range(0,i):
			a[j] = a[j]+1
	else:
		for j in range(i+1,N):
			a[j] = a[j]+1

print(min(a))

### FIXED CODE ###

N = int(input())
S = input()
 
cnt = S[1:].count("E")
ans = cnt
for i in range(1, N):
    if S[i-1] == "W":
        cnt += 1
    if S[i] == "E":
        cnt -= 1
    ans = min(ans, cnt)
 
print(ans)
### BUGGY CODE ###

X=raw_input()
while 1:
    if 'SSSSSSSSSSSSSSSSSSSSSSSSSTTTTTTTTTTTTTTTTTTTTTTTTT' in X:
       X=X.replace('SSSSSSSSSSSSSSSSSSSSSSSSSTTTTTTTTTTTTTTTTTTTTTTTTT','')
    elif 'SSSSSSSSSSSSSSSSSSSSTTTTTTTTTTTTTTTTTTTT' in X:
       X=X.replace('SSSSSSSSSSSSSSSSSSSSTTTTTTTTTTTTTTTTTTTT','')
    elif 'SSSSSSSSSSSSSSSTTTTTTTTTTTTTTT' in X:
       X=X.replace('SSSSSSSSSSSSSSSTTTTTTTTTTTTTTT','')
    elif 'SSSSSSSSSSTTTTTTTTTT' in X:
       X=X.replace('SSSSSSSSSSTTTTTTTTTT','')
    elif 'SSSSSSSTTTTTTT' in X:
       X=X.replace('SSSSSSSTTTTTTT','')
    elif 'SSSSSTTTTT' in X:
       X=X.replace('SSSSSTTTTT','')
    elif 'SSSTTT' in X:
       X=X.replace('SSSTTT','')
    elif 'ST' in X:
       X=X.replace('ST','')
    else:
        break
print len(X)

### FIXED CODE ###

X=raw_input()
l=[0,0]
for i in X:
    if i=='S':
        l[0]+=1
    elif i=='T' and l[0]>0:
        l[0]-=1
    else:
        l[1]+=1
print sum(l)
### BUGGY CODE ###

R,G,B,n = map(int,input().split())

ans=0
for r in range(n//R+1):
    for g in range(n//G+1):
        tmp=n-r*R-g*G
        if tmp%B==0 and tmp//B>=0:
            ans+=1

print(ans)


### FIXED CODE ###

R,G,B,n = map(int,input().split())

ans=0
for r in range(n//R+1):
    for g in range(n//G+1):
        tmp=n-r*R-g*G
        if tmp%B==0 and tmp//B>=0:
            ans+=1

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

n=int(input())
ai = list(map(int,input().split()))
sum = 0
for i in range(0,n-1):
    for k in range(1,n-i):
      sum += ai[i]*ai[i+k]
sum %= 1000000007
print(sum)

### FIXED CODE ###

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

for i in range(N):
    ans += A[i]*A[i]
last += sum(A)*sum(A)
last -= ans
last //= 2
print(last % 1000000007)
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()]
for j in range(1,N+1):
    print(A.count(j))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
a = [0] * N

for i in A:
    a[i-1] += 1

for j in range(N):
    print(a[j])
### BUGGY CODE ###

k = int(input())
n = 7

if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

ans = 1
while True:
    if n % k == 0:
        print(ans)
        exit()
    n = (n*10 + 7)
    ans += 1

### FIXED CODE ###

k = int(input())
n = 7

if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

ans = 1
while True:
    if n % k == 0:
        print(ans)
        exit()
    n = (n*10 + 7)%k
    ans += 1
### BUGGY CODE ###

def solve():
    n = int(input())
    a = list(map(int, input().split()))

    b= []
    cnt = 0
    while cnt < n:
        b = b[::-1] + [a[cnt]]
        cnt += 1


    return b[::-1]
    

print(*solve())


### FIXED CODE ###

def solve():
    n = int(input())
    a = list(map(int, input().split()))

    b = a[1::2]
    c = a[::2]
    
    if len(a)%2 == 0:
        return b[::-1] + c
    else:
        return c[::-1] + b
    

print(*solve())
### BUGGY CODE ###

from math import gcd as bltin_gcd
def coprime(a, b):
    return bltin_gcd(a, b) == 1

n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
    cnt=0
    for j in range(n):
        if i!=j:
            if a[i]%a[j]==0:
                cnt+=1
    if cnt==0:
        ans+=1
print(ans)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort()
aMax=a[-1]
isAns=[0]*(aMax+1) ## 1=ans 2=multiple or plural
for ai in a:
    isAns[ai]+=1
    if isAns[ai]==1:
      for j in range(2*ai,aMax+1,ai):
        isAns[j]+=2

print(isAns.count(1))
### BUGGY CODE ###

# encoding: utf-8
N, M = list(map(int, input().split()))
P=map(int, input().split())
Acnt = [0 for i in range(M)]
sym = 0

for A in P:
    sym = (sym + A) % M
    Acnt[sym] += 1
L=[cnt * (cnt - 1) for cnt in Acnt]
print(int(Acnt[0] + sum(L) / 2))



### FIXED CODE ###

from collections import defaultdict
N,M=map(int,input().split())
A=[int(i) for i in input().split()]
P=[0]*(N+1)
for i in range(N):
    P[i+1]=P[i]+A[i]
dd=defaultdict(int)
for p in P:
    dd[p%M]+=1
ans=0
def dou(x):
    return (x*(x-1))//2
for s in dd.values():
    ans+=dou(s)
print(ans)
### BUGGY CODE ###

import math

s = input()
K = int(input())

n=0
z=[]
while(n<len(s)):
    x=[]
    for i in range(len(s)-n):
        x.append(s[i:i+n+1])
    y = sorted(set(x+z))
    z = y[:K]
    n += 1
print(sorted(set(z))[K-1])

### FIXED CODE ###


import math

s = input()
K = int(input())

init = sorted(set(list(s)))[:K]
n=0
z=[]
while(n<len(s)):
    if n > 500: break
    x=[]
    for i in range(len(s)-n):
        if s[i] in init:
            x.append(s[i:i+n+1])
    y = sorted(set(x+z))
    z = y[:K]
    n += 1
print(sorted(set(z))[K-1])