N = int(eval(input()))



ans = 0

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

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

        ans += i



print(ans)

N = int(eval(input()))





def sum(n):

    return (n + 1) * n // 2





print((sum(N) - sum(N // 3) * 3 - sum(N // 5) * 5 + sum(N // 15) * 15))

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

N = int(eval(input()))


def sum(n):
    return (n + 1) * n // 2


print((sum(N) - sum(N // 3) * 3 - sum(N // 5) * 5 + sum(N // 15) * 15))

-ans = 0 -for i in range(1, N + 1): -    if i % 3 != 0 and i % 5 != 0: -        ans += i -print(ans) + + +def sum(n): +    return (n + 1) * n // 2 + + +print((sum(N) - sum(N // 3) * 3 - sum(N // 5) * 5 + sum(N // 15) * 15))