N = int(eval(input()))

list = []

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

    list.append(i)

for i in range(1,(N+3)//3):

    list[3*i-1] = 0

for i in range(1,(N+5)//5):

    list[5*i-1] = 0

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



ans = 0

for i in range(n+1):

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

        ans += i

print(ans)
N = int(eval(input()))
list = []
for i in range(1, N + 1):
    list.append(i)
for i in range(1, (N + 3) // 3):
    list[3 * i - 1] = 0
for i in range(1, (N + 5) // 5):
    list[5 * i - 1] = 0
print((sum(list)))

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

-N = int(eval(input())) -list = [] -for i in range(1, N + 1): -    list.append(i) -for i in range(1, (N + 3) // 3): -    list[3 * i - 1] = 0 -for i in range(1, (N + 5) // 5): -    list[5 * i - 1] = 0 -print((sum(list))) +n = int(eval(input())) +ans = 0 +for i in range(n + 1): +    if i % 3 != 0 and i % 5 != 0: +        ans += i +print(ans)