n = int(eval(input()))



num = [i for i in range(1, n + 1)]

for i in range(n):

    if (num[i] % 3 == 0) or (num[i] % 5 == 0):

        num[i] = 0



print((sum(num)))

n = int(eval(input()))



cnt = 0

for i in range(n+1):

    if (i % 3 == 0) or (i % 5 == 0):

        continue

    cnt += i



print(cnt)

n = int(eval(input()))
num = [i for i in range(1, n + 1)]
for i in range(n):
    if (num[i] % 3 == 0) or (num[i] % 5 == 0):
        num[i] = 0
print((sum(num)))

n = int(eval(input()))
cnt = 0
for i in range(n + 1):
    if (i % 3 == 0) or (i % 5 == 0):
        continue
    cnt += i
print(cnt)

-num = [i for i in range(1, n + 1)] -for i in range(n): -    if (num[i] % 3 == 0) or (num[i] % 5 == 0): -        num[i] = 0 -print((sum(num))) +cnt = 0 +for i in range(n + 1): +    if (i % 3 == 0) or (i % 5 == 0): +        continue +    cnt += i +print(cnt)