n = int(eval(input()))

us = set(i for i in range(1, n + 1))

m3 = set(i for i in range(3, n + 1, 3))

m5 = set(i for i in range(5, n + 1, 5))

print((sum(list(us - m3 - m5))))
n = int(eval(input()))

sum = 0

for i in range(1, n + 1):

    if i % 3 != 0 and i % 5 != 0:

        sum += i

print(sum)
n = int(eval(input()))
us = set(i for i in range(1, n + 1))
m3 = set(i for i in range(3, n + 1, 3))
m5 = set(i for i in range(5, n + 1, 5))
print((sum(list(us - m3 - m5))))

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

-us = set(i for i in range(1, n + 1)) -m3 = set(i for i in range(3, n + 1, 3)) -m5 = set(i for i in range(5, n + 1, 5)) -print((sum(list(us - m3 - m5)))) +sum = 0 +for i in range(1, n + 1): +    if i % 3 != 0 and i % 5 != 0: +        sum += i +print(sum)