N = int(eval(input()))

S = 0

for i in range(0,N):

  if (i+1) % 3 != 0 and (i+1) % 5 != 0:

    S = S + i+1

print(S)
N = int(eval(input()))

S = 0

for x in range(0,N+1):

    if (x % 3) != 0 and (x % 5) != 0:

        S += x

    else:

        S += 0

print(S)
N = int(eval(input()))
S = 0
for i in range(0, N):
    if (i + 1) % 3 != 0 and (i + 1) % 5 != 0:
        S = S + i + 1
print(S)

N = int(eval(input()))
S = 0
for x in range(0, N + 1):
    if (x % 3) != 0 and (x % 5) != 0:
        S += x
    else:
        S += 0
print(S)

-for i in range(0, N): -    if (i + 1) % 3 != 0 and (i + 1) % 5 != 0: -        S = S + i + 1 +for x in range(0, N + 1): +    if (x % 3) != 0 and (x % 5) != 0: +        S += x +    else: +        S += 0