Problem:
 Score : 200 points    Problem Statement Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:   Red boxes, each containing R red balls  Green boxes, each containing G green balls  Blue boxes, each containing B blue balls   Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes.
How many triples of non-negative integers (r,g,b) achieve this?      Constraints  All values in input are integers.  1 \leq R,G,B,N \leq 3000         Input Input is given from Standard Input in the following format:  R  G  B  N       Output Print the answer.        Sample Input 1 1 2 3 4      Sample Output 1 4  Four triples achieve the objective, as follows:   (4,0,0)  (2,1,0)  (1,0,1)  (0,2,0)        Sample Input 2 13 1 4 3000      Sample Output 2 87058

Solution (Python):
R,G,B,N = map(int,input().split(" "))

count = 0
for r in range(N+1):
    left = N - R*r
    if left < 0:
        break
    for g in range(N+1):
        left2 = left - g*G
        if left2 < 0:
            break
        if left2%B == 0:
            count += 1

print(count)

Solution (Python):
R, G, B, N = list(map(int, input().split()))

count = 0
for r in range(3001):
    if r*R > N:
        break
    for g in range(3001):
        n = N-(r*R+g*G)
        if n<0:
            break
        if n%B == 0:
            count += 1
print(count)

Solution (Python):
R, G, B, N = map(int, input().split())
list_a = [R, G, B]
list_a.sort()
ans = 0
for i in range(N//list_a[2]+1):
  nn = N-i*list_a[2]
  for j in range(nn//list_a[1]+1):
    nnn = nn-j*list_a[1]
    if nnn%list_a[0] == 0:
      ans+=1
print(ans)

Solution (Python):
R, G, B, N = list(map(int, input().split()))

ans = 0

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


print(ans)

Solution (Python):
r,g,b,n = map(int,input().split())
f = [r,g,b]
f.sort()
r,g,b = f[2],f[1],f[0]

ans = 0
R = 0

while 1:
     G = 0
     if R*r>n:
          break
     while 1:
          if R*r+G*g>n:
               break
          if (n-R*r-G*g)%b == 0:
               ans += 1
          G += 1
     R += 1
     
print(ans)

Solution (Python):
R,G,B,N = list(map(int, input().split()))
ans = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        now = N - r*R - g*G
        if  now >= 0 and now % B == 0:
            ans += 1
print(ans)

Solution (Python):

a=list(map(int,input().split(" ")))
rr=a[0]
rg=a[1]
rb=a[2]
N=a[3]
count=0
for nr in range(0,N//rr+1):
    for ng in range(0,N//rg+1):
        tb=N-rr*nr-rg*ng
        if tb>=0 and tb%rb==0:
            count+=1
print(count)

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

ct = 0
R, G, B, N = na()
for r in range((N // R) + 1):
    for g in range((N // G) + 1):
        if N < r * R + g * G:
            break
        elif (N - r * R - g * G) % B == 0:
            ct += 1
print(ct)

Solution (Python):
R,G,B,N = map(int,input().split())
rgb = [R,G,B]
rgb.sort()
cnt = 0

N_b = N//rgb[2]
for i in range(N_b,-1,-1):
    x = N - i*rgb[2]

    N_g = x//rgb[1]
    for j in range(N_g,-1,-1):

        if (x - j*rgb[1])%rgb[0]==0:
            cnt += 1
print(cnt)

Solution (Python):
R, G, B, N = map(int, raw_input().split())

count = 0
r_max = int(N / R)+1
g_max = int(N / G)+1

for r in xrange(r_max):
    rest_val = N - R*r
    for g in xrange(g_max):
        rest_val2 = rest_val - G * g
        if rest_val2 < 0: break
        if rest_val2 % B == 0:
            
            count += 1

print count

Solution (Python):
R, G, B, N = map(int, input().split())

cnt = 0
for i in range(N + 1):
    for j in range(N + 1 - i * R):
        if i * R + j * G <= N and (N - i * R - j * G) % B == 0:
            cnt += 1
            
print(cnt)

Solution (Python):
R,G,B,N=(int(x) for x in input().split())
count=0
for r in range(0,N+1):
    if (r*R>N):
        break
    for g in range(0,N-r*R+1):
        if(r*R-g*G>N):
            break
        elif((N-r*R-g*G)%B==0 and (N-r*R-g*G)/B>=0):
            count+=1
print(count)

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


ret = 0
for i in range(n//r+1):
    for j in range(n//g+1):

        tmp = r*i+g*j
        if tmp > n:
            continue
        if (n-tmp)%b == 0:

            ret += 1
print(ret)

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(R, G, B, N):
    ans = 0
    r = -R
    for i in range(N//R + 1):
        r += R
        g = -G
        for j in range((N-r)//G + 1):
            g += G
            if (N-r-g) % B == 0:
                ans += 1

    return ans


def main():
    R, G, B, N = read_int_n()
    
    print(slv(R, G, B, N))


if __name__ == '__main__':
    main()

Solution (Python):
r, g, b, n = map(int, input().split())
count=0
for i in range(0,(int)(n/r)+1):
    for j in range(0, (int)((n-i*r)/g)+1):
        v = n-i*r-j*g
        if v%b == 0 and v>=0:
            count+=1

print(count)

Solution (Python):
R,G,B,N = map(int, input().split())
ans = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        if N-r*R-g*G >= 0 and (N-r*R-g*G) % B == 0:
            ans += 1

print(ans)

Solution (Python):
R, G, B, N = map(int, input().split())

counter = 0
for r in range(3001):
    for g in range(3001):
        bB = N - r * R - g * G
        if bB < 0:
            break
        if bB % B == 0:
            counter += 1
print(counter)

Solution (Python):
R,G,B,N = map(int,input().split())
count = 0

r = N //R


for i in range(r+1):
    M = N - R * i
    g = M // G
    for j in range(g+1):
        O = M - G * j
        if O % B == 0:
            count += 1

print(count)

Solution (Python):
R, G, B, N = map(int, input().split())
x = 0
for r in range(N // R + 1):
	M = N - R * r
	for g in range(M // G + 1):
		if (M - G * g) % B == 0:
			x += 1
print(x)

Solution (Python):
R,G,B,N = map(int,input().split(' '))
count = 0
rr = int(N/R) +1
gg = int(N/G) +1
bb = int(N/B) +1
for r in range(rr):
    for g in range(gg):
        b = N - r*R - g*G
        if b<0:
            break
        if b%B==0:
            count+=1
print(count)

Solution (Python):
R, G, B, N = map(int, input().split())
ans = 0
for r in range(N//R+1):
    for g in range(N//G + 1):
        if (N-r*R-g*G) % B == 0:
            b = (N-r*R-g*G)//B
            if 0 <= b and r*R+g*G+b*B == N:
                ans += 1
print(ans)

Solution (Python):
[r, g, b, n] = [int(i) for i in input().split()]

ans = 0
for i in range( n//r+ 1):
    for j in range(n//g + 1):
            tmp =  n - r * i - g * j
            if tmp >= 0:
                if tmp % b == 0:
                    ans += 1
            else:
                break
print(ans)

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

ans = 0

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

Solution (Python):
R,G,B,N=list(map(int, input().split()))
arr = [R,G,B]
arr = sorted(arr, reverse=True)
R,G,B = arr

cnt = 0
for r in range(N//R+1):
    for g in range((N-r*R)//G+1):
        tmp = (N-(r*R+g*G))
        if tmp>=0:
            if tmp%B==0:
                cnt += 1
print(cnt)

Solution (Python):
import math
r, g, b, n = map(int, input().split())
ans = 0
for r_num in range(math.floor(n/r)+1):
    for g_num in range(math.floor(math.floor(n - r*r_num)/g)+1):
        if ((n - (r_num * r) - (g_num * g)) % b == 0):
            ans += 1
print(ans)

Solution (Python):
r,g,y,n=map(int,input().split())
a=0
b=0
c=0
count=0


m=n
for i in range((n//r)+1):
    m=m-r*i
    for j in range((m//g)+1):
        c=m-j*g
        if c%y==0 and c>=0 :
            count+=1

    m=n

print(count)

Solution (Python):

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

result = 0
for i in range(n+1):
    r_sp = i*r
    if r_sp > n:
        break
    for j in range(n+1):
        g_sp = j*g
        if g_sp > n:
            break

        rg = r_sp + g_sp
        if rg > n:
            break

        if (n-rg) % b == 0:
            result += 1

print(result)

Solution (Python):
R,G,B,n=map(int,input().split())
def cou(R,G,B,n):
    c=0
    for i in range(n+1):
        r=R*i
        if r>n:
            break
        for j in range(n+1):
            g=G*j
            if r+g>n:
                break
            b=n-r-g
            if b%B==0:
                c+=1
    return c
print(cou(R,G,B,n))

Solution (Python):
R,G,B,N = map(int,input().split())

rcount=0
gcount=0
b=0
ans = 0

while rcount <= N:
    gcount = 0
    while rcount+gcount <= N:
        if (N - (rcount + gcount) ) % B == 0 :
            ans += 1
        gcount += G
    rcount += R

print(ans)

Solution (Python):
r, g, b, n = list(map(int, input().split()))

import math

counter = 0
for x in range(math.ceil(n / r) + 1):
    left = n - x * r

    for y in range(math.ceil(left / g) + 1):
        left2 = left - y * g

        if left2 >= 0 and left2 % b == 0:
            counter += 1
        
print(counter)

Solution (Python):
from math import ceil

r, g, b, n = map(int, input().split())
cnt = 0
for i in range(ceil(n / r) + 1):
    for j in range(ceil(n / g) + 1):
        if i * r + j * g > n:
            break
        if i * r + j * g == n:
            cnt += 1
            continue
        else:
            tmp = n - (i * r + j * g)
            if tmp % b == 0:
                cnt += 1
print(cnt)

Solution (Python):
def main(R, G, B, N):
    R, G, B = sorted((R, G, B))
    n = 0
    for b in range(N // B + 1):
        xb = N - b * B
        for g in range(xb // G + 1):
            xg = xb - g * G
            if xg % R == 0:
                n += 1   
    return n

print(main(*map(int, input().split())))

Solution (Python):
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)

Solution (Python):
import sys
input = sys.stdin.readline

import numpy as np

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

count = 0
R_limit = N // R

for i in range(R_limit,-1,-1):
    N_temp = N - i*R
    G_limit = N_temp // G
    for j in range(G_limit,-1,-1):
        N_temp2 = N_temp - j * G
        B_mod = N_temp2 % B
        if B_mod == 0:
            count = count+1

print(count)

Solution (Python):



from collections import defaultdict

R, G, B, N = map(int, input().rstrip().split(' '))
A = [R, G, B]

dp = defaultdict(lambda: defaultdict(lambda: -1))
def rec(i, n):
    if dp[i][n] != -1:
        return dp[i][n]
    if n == 0:
        return 1
    if i == 2:
        return n % A[2] == 0
       
    temp = 0
    for j in range(n // A[i] + 1):
        temp += rec(i + 1, n - j * A[i])
        
    dp[i][n] = temp
    
    return temp
    
print(rec(0, N))

Solution (Python):
*lst,N = map(int, input().split())

lst.sort(reverse=True)

count = 0
for i in range(N // lst[0] + 1):
    for j in range((N - i * lst[0]) // lst[1] + 1):
        if (N - i * lst[0] - j * lst[1]) % lst[2] == 0:
            count += 1
print(count)

Solution (Python):
def getlist():
	return list(map(int, input().split()))

R, G, B, N = getlist()
ans = 0
for i in range(3001):
	for j in range(3001 - i):
		x = R * i + G * j
		if N >= x and (N - x) % B == 0:
			ans += 1

print(ans)

Solution (Python):
R,G,B,N = map(int,input().split())

count = 0
for r in range(0,N // R + 1):
    for g in range(0,N // G + 1):
        left = (N - r * R - g * G)
        if left < 0:
            continue
        if left % B == 0:
            count += 1

print(count)

Solution (Python):
R, G, B, N = map(int, input().split())
num = 0
for i in range(N + 1):
    if N - R * i < 0:
        break
    for j in range(N + 1):
        if N - R * i - G * j < 0:
            break
        if 0 <= N - R * i - G * j and (N - R * i - G * j) % B == 0:
            num += 1

print(num)

Solution (Python):
R, G, B, N = map(int, input().split())
ans = 0
mb = N//B+1
for r in range(N//R+1):
    for g in range(N//G+1):
        b = (N - r*R - g*G)/B
        if 0 <= b < mb and int(b) == b:
            ans += 1
print(ans)

Solution (Python):
inpl = lambda: list(map(int,input().split()))
R,G,B,N = inpl()
(R,G,B) = sorted([R,G,B])
ans = 0
for b in range(N//B+1):
    N1 = N - b*B
    for g in range(N1//G+1):
        N2 = N1 - g*G
        if N2 % R == 0:
            ans += 1
print(ans)

Solution (Python):
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect, math
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

R,G,B,N = read_int()

def solve():
    ans = 0

    for i in range(0, N + 1, R):
        res = i
        if res > N: continue
        for j in range(0, N + 1 - res, G):
            res = i + j
            if res <= N and (N - res) % B == 0:
                ans += 1
    return ans

if __name__ == "__main__":
    print(solve())

Solution (Python):
R,G,B,N = map(int,input().split())
rmax = N // R
gmax = N // G
bmax = N // B
ans = 0
for r in range(rmax+1):
    for g in range(gmax+1):
        if (N - (R*r + G*g)) % B == 0 and 0 <= (N - (R*r + G*g) )// B <= bmax: 
            ans += 1
print(ans)

Solution (Python):
R, G, B, N = [int(c) for c in input().split()]

n=0
for r in range(N//R+1):
    N2 = N-R*r
    if N2==0:
        n+=1
        continue
    
    for g in range(N2//G+1):
        if (N2-G*g)%B==0:
            n+=1

print(n)

Solution (Python):
r, g, b, n = map(int, input().split())
cnt = 0
nr = 0
while nr * r <= n:
    m = n - nr * r
    ng = 0
    while ng * g <= m:
        l = m - ng * g
        if not l % b:
            cnt += 1
        ng += 1
    nr += 1
print(cnt)

Solution (Python):



def main():
    r, g, b, n = map(int, input().split())
    comb = list()
    ans = 0

    for i in range(3000 + 1):
        for j in range(3000 + 1):
            comb.append(r * i + g * j)

    for c in comb:
        if (n - c) >= 0 and (n - c) % b == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
R, G, B, N = map(int, input().split())

counter = 0
for r in range(N//R + 1):
    M = N-r*R
    for g in range(M//G + 1):
        if (M - G*g) % B == 0:
            counter += 1
print(counter)

Solution (Python):
def li():
    return list(map(int, input().split()))


def combination2(a, b, n):
    
    com2 = 0
    a_quot = n // a + 1
    for j in range(a_quot):
        com2 = com2 + combination1(b, n - j * a)
    return com2


def combination1(a, n):
    
    if n % a == 0:
        return 1
    else:
        return 0


[r, g, b, n] = li()
r_quot = n // r + 1
com_num = 0
for i in range(r_quot):
    com_num = com_num + combination2(g, b, n - i * r)
print(com_num)

Solution (Python):
R,G,B,N=map(int,input().split())

res = 0
for i in range(0, N//R + 1):
    for j in range(0, (N-i*R)//G + 1):
        if (N-i*R-j*G)%B == 0:
            res+=1

print(res)

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

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

Solution (Python):

def main():
    R, G, B, N = map(int, input().split())

    count = 0
    for r in range(3001):
        if r*R > N:
            break

        for g in range(3001):
            rest = N - (r*R + g*G)
            if rest < 0:
                break
            if rest % B == 0:
                count += 1
    print(count)


if __name__ == "__main__":
    main()

Solution (Python):
R, G, B, N = map(int, input().split())

ans = 0
for i in range((N//R)+1):
    temp = N - i*R
    for j in range((temp//G)+1):
        temp2 = N - i*R - j*G
        if temp2 % B == 0:
            ans += 1
            
print(ans)

Solution (Python):
R, G, B, N = map(int, input().split())
ans = 0
for i in range(N//R+1):
    for j in range(N//G+1):
        n = N - R*i - G*j
        if n < 0:
          break
        if n % B == 0:
            ans += 1
print(ans)

Solution (Python):
R, G, B, N = [int(_) for _ in input().split()]
cnt = 0

for i in range(0, N//R+1):
    for j in range(0, (N-R*i)//G + 1):
        if (N-R*i-G*j) % B == 0:
            cnt += 1
print(cnt)

Solution (Python):
import numpy as np
r,g,b,n = map(int, input().split())


m1,m2,m3 = sorted([r,g,b])
count = 0
for k in range((n // m3)+1):
  now_n = n-k*m3
  for u in range((now_n // m2)+1):
    if (now_n - m2*u) % m1 == 0:
      count += 1
print(count)

Solution (Python):
R,G,B,N = map(int,input().split())

ct = 0

for r in range(int(N/R)+1):
  N_ = N - R*r
  if N_==0:
    ct+=1
    continue
  for g in range(int(N_/G)+1):
    N__ = N_ - G*g
   	
    if N__%B == 0:
      ct+=1
      
print("{0}".format(ct))

Solution (Python):
r, g, b, n = list(map(int, input().split()))
ans = 0
for i in range(n//r+1):
  for j in range(n//b+1):
    ij = i*r + j*b
    k = (n-ij)//g
    if not (i==k==j==0) and (k>=0 and (n-ij)%g==0):
      ans += 1
print(ans)

Solution (Python):
r,g,b,n = list(map(int,input().split()))

a = sorted([r,g,b])
count = 0
for i in range(0,n//a[2]+1):
    for j in range(0,(n-i*a[2])//a[1]+1):
        if (n-a[2]*i-a[1]*j)%a[0] == 0:
            count += 1
print(count)

Solution (Python):
R,G,B,N = [int(x) for x in 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)

Solution (Python):

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

cnt = 0
for ri in range(n+1):
    if r*ri>n:
        break
    for gi in range(n+1):
        x = n - r*ri - g*gi
        if x<0:
            break
        if x%b==0:
            cnt += 1

print(cnt)

Solution (Python):
import math

R,G,B,N=map(int,input().split())
ans=0
x=[R,G,B]
x.sort(reverse=True)

for i in range(N//x[0]+1):
    n=N-i*x[0]
    for j in range(n//x[1]+1):
        if (n-j*x[1])%x[2]==0: ans+=1

print(ans)

Solution (Python):
nums = list(map(int, input().split()))
R, G, B, N = nums[0], nums[1], nums[2], nums[3]

cnt = 0
for i in range(N // R + 1):
    rem = N - i*R
    for j in range(rem // G + 1):
        rem = N - i*R - j*G
        if rem % B == 0:
            cnt += 1
print(cnt)

Solution (Python):
R, G, B, N = map(int, input().split())

ans = 0
for r in range(N // R + 1):
    for g in range((N - R * r) // G + 1):
        if (N - R * r - G * g) % B == 0:
            ans += 1
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

R, G, B, N = [int(x) for x in input().split()]

counter = 0
for r in range(N//R + 1):
    for g in range((N-R*r)//G + 1):
        if (N-R*r-G*g)%B == 0: counter += 1

print(counter)

Solution (Python):
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

r,g,b,n = na()
ans=0
for i in range(n//r+1):
    a = n-r*i
    for j in range(a//g+1):
        if (a-g*j)%b == 0:
            ans+=1

print(ans)

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

count = 0
for i in range(0,3000+1):
    for j in range(0,3000+1):
        rem = n - i*r - j*g
        if rem>=0 and rem%b == 0:
            count += 1

print(count)

Solution (Python):



def solve(r, g, b, n):
    res = 0
    for i in range(n // r + 1):
        rest = n - i * r
        for j in range(rest // g + 1):
            rest2 = n - (i * r + j * g)
            if rest2 >= 0 and rest2 % b == 0:
                res += 1
    return res


def main():
    r, g, b, n = (int(z) for z in input().split())
    res = solve(r, g, b, n)
    print(res)


if __name__ == "__main__":
    main()

Solution (Python):
R, G, B, N = map(int,input().split())
ans = 0

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

print(ans)

Solution (Python):
R,G,B,N = map(int,input().split())

ans = 0


for r in range(N+1) :
    
    for g in range(N+1) :
        if (N - (r*R + g*G)) < 0 : continue
        if (N - (r*R + g*G)) % B == 0 :
            ans += 1
            
print(ans)

Solution (Python):
R, G, B, N = map(int,input().split())
count = 0
i_range = N//R+1
j_range = N//G+1

for i in range (N//R+1):
    for j in range (N//G+1):
        if (N - i*R - j*G)%B == 0 and (N - i*R - j*G)>=0:
            count += 1
print(count)

Solution (Python):
R, G, B, N = map(int, input().split())

cnt = 0

for i in range(N//R + 1):
    for j in range(N//G + 1):
        sum = N - i * R - j * G
        if sum >= 0 and sum % B == 0:
            cnt += 1

print(cnt)

Solution (Python):



def solv(r, g, b, n):
    ans = 0
    r, g, b = sorted([r, g, b])
    for bn in range(n // b + 1):
        n1 = n - bn * b
        for gn in range(n1 // g + 1):
            n2 = n1 - gn * g
            if n2 % r == 0:
                ans += 1
    return ans


if __name__ == '__main__':

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

    ans = solv(r, g, b, n)

    print(ans)

Solution (Python):

import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(R: int, G: int, B: int, N: int):
    ret = 0
    for r in range((N // R) + 1):
        rc = R * r
        for g in range((N // G) + 1):
            gc = G * g
            bc = N - rc - gc
            if (0 <= bc) and  (bc % B == 0):
                ret += 1
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  
    G = int(next(tokens))  
    B = int(next(tokens))  
    N = int(next(tokens))  
    result = solve(R, G, B, N)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()

Solution (Python):
R,G,B,N=(int(x) for x in input().split())
result=0

for r in range(N+1):
    N2=N-r*R
    if N2<0:
        break
    for g in range(N+1):
        N3=N2-g*G
        if N3<0:
            break
        if N3%B==0:
            result+=1

print(result)

Solution (Python):
r, g, b, n = map(int, input().split())
count = 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:
            count += 1
print(count)

Solution (Python):
def task_b():
    r, g, b, n = map(int, input().split())
    c = 0
    for i in range(n // r + 1):
        ni = n - r * i
        for j in range(ni // g + 1):
            nj = ni - g * j
            if nj % b == 0:
                c += 1
    print(c)
task_b()

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

Solution (Python):
R,G,B,N = map(int, input().split())
ans = 0
for r in range(N//R+1):
    A = N-(r*R)
    for g in range(A//G+1):
        if (A -(g*G))%B == 0:
            ans += 1
print(ans)

Solution (Python):
R,G,B,N = map(int,input().split())
ans = 0
for r in range(N+1):
    t1 = N - r*R
    if t1 < 0: break
    for g in range(N+1):
        t2 = t1 - g*G
        if t2 < 0: break
        if t2 % B == 0: ans += 1

print(ans)

Solution (Python):
import math
r, b, g, n = map(int, input().split(' '))
ans = 0

r1 = int(math.ceil(n/r))
b1 = int(math.ceil(n/b))
g1 = int(math.ceil(n/g))




for x in range(r1 + 1):
    for y in range(b1 + 1):
        tmp = n
        tmp -= x * r
        tmp -= y * b

        

        if tmp >= 0 and tmp % g == 0:
            ans += 1

        

print(ans)

Solution (Python):
R,G,B,N = list(map(int,input().split()))
r_max = N//R+1
ans = 0
for r in range(r_max):
	g_max = (N-r*R)//G+1
	for g in range(g_max):
		if (N-r*R-g*G)%B == 0:
			ans += 1
print(ans)

Solution (Python):
R, G, B, N = map(int, input().split())

cnt = 0
for r in range(N // R + 1):
    N_r = N - R * r
    for g in range(N_r // G + 1):
        N_rg = N_r - G * g
        if N_rg % B == 0:
            cnt += 1

print(cnt)

Solution (Python):
R,G,B,N = map(int,input().split())
cnt = 0
for r in range(3001):
    if R*r <= N:
        for g in range(3001):
            if N - R*r -G*g >= 0:
                if (N - R*r -G*g)%B == 0:
                    cnt += 1
print(cnt)

Solution (Python):
R,G,B,N=map(int,input().split())
import math
ans=0
a=math.floor(N/R)
for i in range(a+1):
    nokori=N-R*i
    b=math.floor(nokori/G)
    for j in range(b+1):
        nokori2=nokori-j*G
        if nokori2%B==0:
            ans+=1
        else:
            pass
print(ans)

Solution (Python):
import sys

R, G, B, N = list(map(int, sys.stdin.readline().strip().split(" ")))

count = 0

for r in range(int(N/R) + 1):
    N1 = N - R*r
    for g in range(int(N1/G) + 1):
        N2 = N1 - G*g
        if N2 % B == 0:
            count += 1
        
        
        
print(count)

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

Solution (Python):
R,G,B,N = map(int,input().split())
ans = 0
for r in range(3001):
    for g in range(3001):
        remain = N - r*R - g*G
        if remain >= 0 and remain % B == 0:
            ans += 1
print(ans)

Solution (Python):
R, G, B, N = [int(i) for i in input().split()]

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

print(count)

Solution (Python):
r, g, b, n = map(int, input().split())
ans = 0
for i in range(n + 1):
    for j in range(n + 1):
        if i * r + j * g == n:
            ans += 1
        elif (n - (i * r + j * g)) >= 0 and (n - (i * r + j * g)) % b == 0:
            ans += 1
print(ans)

Solution (Python):
s = input().split()
r,g,b,n=int(s[0]),int(s[1]),int(s[2]),int(s[3])
k = [r,g,b]
k.sort()
a,b,c=k[0],k[1],k[2]
co = 0
for i in range(n//c+1):
    p = n-i*c
    for j in range(p//b+1):
        q = p-j*b
        if q>=0 and q%a==0:
            co+=1
print(co)

Solution (Python):
R, G, B, n = map(int, input().split())
ans = 0

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

print(ans)

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

Solution (Python):


R, G, B, N = [int(i) for i in input().split()]

cnt = 0
for i in range(N // R + 1):
    r = i * R
    for j in range((N - r) // G + 1):
        g = j * G

        b = N - r - g

        if b % B == 0:
            cnt += 1

print(cnt)

Solution (Python):
from collections import defaultdict, deque, Counter
def inpl(): return list(map(int, input().split()))

R, G, B, N = inpl()
ans = 0
for r in range(N//R + 1):
    for g in range(N//G + 1):
        tmp = N - R*r - G*g
        if tmp < 0:
            break
        if (tmp%B == 0):
            ans += 1
print(ans)

Solution (Python):
r,g,b,n = map(int,input().split())
R = int(n/r)
G = int(n/g)
ans = 0
for i in range(0,R+1):
    for j in range(0,G+1):
        temp = i*r+j*g
        if (n-temp)%b==0 and n>=temp:
            ans += 1
print(ans)

Solution (Python):


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

def submit():
    r, g, b, n = read_input()

    r_max = n // r
    g_max = n // g

    count = 0
    for rc in range(r_max + 1):
        for gc in range(g_max + 1):
            rest = n - (r*rc) - (g*gc)
            if rest < 0:
                continue

            bc, remain = divmod(rest, b)
            if remain == 0:
                count += 1

    print(count)

if __name__ == '__main__':
    submit()

Solution (Python):
R, G, B, N = [int(i) for i in input().split()]
ans = 0
for r in range(3001):
    for g in range(3001):
        mod = N - r * R - g * G
        if mod >= 0 and mod % B == 0:
            ans += 1

print(ans)

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

Solution (Python):
R, G, B, N = map(int, input().split())

count = 0

for r in range(N//R + 1):
    for g in range(N//G + 1):
        if 0 <= (N - R * r - G * g) and (N - R * r - G * g) % B == 0:
            count += 1

print(count)

Solution (Python):

import sys


def solve(R: int, G: int, B: int, N: int):
    ans = 0
    for i in range(0, N+1, R):
        for j in range(0, N+1, G):
            x = N - i - j
            if(0 <= x and x%B == 0):
                ans += 1

    print(ans)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  
    G = int(next(tokens))  
    B = int(next(tokens))  
    N = int(next(tokens))  
    solve(R, G, B, N)

if __name__ == '__main__':
    main()

Solution (Python):
R, G, B, N = map(int, input().split())
r = N//R
ans = 0
for i in range(r + 1):
  g = (N - i*R)//G
  for j in range(g + 1):
    if (N - i*R - j*G) % B == 0:
      ans += 1
print(ans)

Solution (Python):
from sys import stdin










R,G,B,N = [int(x) for x in stdin.readline().rstrip().split()]

ans = 0
for r in range(N+1):
  for g in range(N+1):
    bB = N-r*R-g*G
    if bB<0:
      break
    if bB%B==0:
      
      ans += 1
print(ans)

Solution (Python):
R,G,B,N=map(int,input().split())

ans=0
for i in range(0,N+1,R):
  for j in range(i,N+1,G):
    if (N-j)%B==0:
      ans+=1
print(ans)

Solution (Python):
r, g, b, N = map(int, input().split())
rr = N//r
ans = 0
for i in range(0,rr+1):
    gg = (N-r*i)//g
    for j in range(0,gg+1):
        if (N-i*r-j*g)%b==0:
            ans += 1
print(ans)

Solution (Python):
def f(r, g, b, n):
    cnt = 0
    for rn in range(n // r + 1):
        for gn in range((n - r * rn) // g + 1):
            if (n - r * rn - g * gn) % b == 0:
                cnt += 1
    print(cnt)

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

Solution (Python):
R, G, B, N = [int(_) for _ in input().split()]

result = 0

for left in range(N, -1, -R):
    for x in range(left, -1, -G):
        if x % B == 0:
            result += 1

print(result)

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