n = int(eval(input()))

ans = 0

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

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

        continue

    ans += i

print(ans)

n = int(eval(input()))



total = {}

for i in (1, 3, 5, 15):

    total[i] = i * (n // i) * (n // i + 1) // 2



print((total[1] - total[3] - total[5] + total[15]))

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

n = int(eval(input()))
total = {}
for i in (1, 3, 5, 15):
    total[i] = i * (n // i) * (n // i + 1) // 2
print((total[1] - total[3] - total[5] + total[15]))

-ans = 0 -for i in range(1, n + 1): -    if i % 3 == 0 or i % 5 == 0: -        continue -    ans += i -print(ans) +total = {} +for i in (1, 3, 5, 15): +    total[i] = i * (n // i) * (n // i + 1) // 2 +print((total[1] - total[3] - total[5] + total[15]))