Buggy python submission (verdict: Time Limit Exceeded):
# def gcd(a_gcd, b_gcd):
#     while b_gcd != 0:
#         a_gcd, b_gcd = b_gcd, a_gcd % b_gcd
#     return a_gcd
#
#
# def lcm(a_lcm, b_lcm):
#     return a_lcm * b // gcd(a_lcm, b_lcm)
#
#
# def max_sum(N_max_sum, a_max_sum):
#     dp = [0] * (N_max_sum + 1)
#     for i in range(N_max_sum):
#         dp[i + 1] = max(dp[i], dp[i] + a_max_sum[i])
#     return dp[N]
#
#
# def knapsack(N_knapsack, W, weight, value):
#     inf = float("inf")
#     dp = [[-inf for _ in range(W+1)] for j in range(N_knapsack + 1)]
#     for i in range(W+1):
#         dp[0][i] = 0
#
#     for i in range(N_knapsack):
#         for w in range(W+1):
#             if weight[i] <= w:
#                 dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
#             else:
#                 dp[i+1][w] = dp[i][w]
#     return dp[N_knapsack][W]


# # s = input()
# # N = int(input())
# N, K = map(int, input().split())
# # b = list(map(int, input().split()))
# # c = [list(map(int, input().split())) for _ in range(N)]
#
#
#
# print(N-K+1)

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

if B > R:
    B, R = R, B
if B > G:
    B, G = G, B

for r_i in range(N + 1):
    if r_i * R > N:
        break
    for g_i in range(N + 1):
        if r_i * R + g_i * G > N:
            break
        if (N - (r_i * R + g_i * G)) % B == 0:
            ans += 1

print(ans)

















Fixed submission:
def gcd(a_gcd, b_gcd):
    while b_gcd != 0:
        a_gcd, b_gcd = b_gcd, a_gcd % b_gcd
    return a_gcd


def lcm(a_lcm, b_lcm):
    return a_lcm * b // gcd(a_lcm, b_lcm)


def max_sum(N_max_sum, a_max_sum):
    dp = [0] * (N_max_sum + 1)
    for i in range(N_max_sum):
        dp[i + 1] = max(dp[i], dp[i] + a_max_sum[i])
    return dp[N]


def knapsack(N_knapsack, W, weight, value):
    inf = float("inf")
    dp = [[-inf for _ in range(W+1)] for j in range(N_knapsack + 1)]
    for i in range(W+1):
        dp[0][i] = 0

    for i in range(N_knapsack):
        for w in range(W+1):
            if weight[i] <= w:
                dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
            else:
                dp[i+1][w] = dp[i][w]
    return dp[N_knapsack][W]


# # s = input()
# # N = int(input())
# N, K = map(int, input().split())
# # b = list(map(int, input().split()))
# # c = [list(map(int, input().split())) for _ in range(N)]
#
#
#
# print(N-K+1)

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

for r_i in range(N + 1):
    if r_i * R > N:
        break
    for g_i in range(N + 1):
        if r_i * R + g_i * G > N:
            break
        if (N - (r_i * R + g_i * G)) % B == 0:
            ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a_gcd, b_gcd):
    while b_gcd != 0:
        a_gcd, b_gcd = b_gcd, a_gcd % b_gcd
    return a_gcd


def lcm(a_lcm, b_lcm):
    return a_lcm * b // gcd(a_lcm, b_lcm)


def max_sum(N_max_sum, a_max_sum):
    dp = [0] * (N_max_sum + 1)
    for i in range(N_max_sum):
        dp[i + 1] = max(dp[i], dp[i] + a_max_sum[i])
    return dp[N]


def knapsack(N_knapsack, W, weight, value):
    inf = float("inf")
    dp = [[-inf for _ in range(W+1)] for j in range(N_knapsack + 1)]
    for i in range(W+1):
        dp[0][i] = 0

    for i in range(N_knapsack):
        for w in range(W+1):
            if weight[i] <= w:
                dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
            else:
                dp[i+1][w] = dp[i][w]
    return dp[N_knapsack][W]


# # s = input()
# # N = int(input())
# N, K = map(int, input().split())
# # b = list(map(int, input().split()))
# # c = [list(map(int, input().split())) for _ in range(N)]
#
#
#
# print(N-K+1)

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

for r_i in range(N + 1):
    if r_i * R > N:
        break
    for g_i in range(N + 1):
        if r_i * R + g_i * G > N:
            break
        if (N - (r_i * R + g_i * G)) % B == 0:
            ans += 1

print(ans)

















Fixed submission:
def gcd(a_gcd, b_gcd):
    while b_gcd != 0:
        a_gcd, b_gcd = b_gcd, a_gcd % b_gcd
    return a_gcd


def lcm(a_lcm, b_lcm):
    return a_lcm * b // gcd(a_lcm, b_lcm)


def max_sum(N_max_sum, a_max_sum):
    dp = [0] * (N_max_sum + 1)
    for i in range(N_max_sum):
        dp[i + 1] = max(dp[i], dp[i] + a_max_sum[i])
    return dp[N]


def knapsack(N_knapsack, W, weight, value):
    inf = float("inf")
    dp = [[-inf for _ in range(W+1)] for j in range(N_knapsack + 1)]
    for i in range(W+1):
        dp[0][i] = 0

    for i in range(N_knapsack):
        for w in range(W+1):
            if weight[i] <= w:
                dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
            else:
                dp[i+1][w] = dp[i][w]
    return dp[N_knapsack][W]


# # s = input()
# # N = int(input())
# N, K = map(int, input().split())
# # b = list(map(int, input().split()))
# # c = [list(map(int, input().split())) for _ in range(N)]
#
#
#
# print(N-K+1)

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

for r_i in range(N + 1):
    if r_i * R > N:
        break
    for g_i in range(N + 1):
        if r_i * R + g_i * G > N:
            break
        if (N - (r_i * R + g_i * G)) % B == 0:
            ans += 1

print(ans)