n = int(eval(input()))

sum = 0

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

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

        sum += i

print(sum)
n = int(eval(input()))

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

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

-sum = 0 -for i in range(1, n + 1): -    if not (i % 15 == 0 or i % 5 == 0 or i % 3 == 0): -        sum += i -print(sum) +print((sum(i for i in range(1, n + 1) if i % 5 != 0 and i % 3 != 0 if i % 15 != 0)))