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()))

#A = list(map(int, input().split()))

amount = (N+1) * N // 2

three = N // 3

three = (three + 1) * 3 * three // 2 if three > 0 else 0

five = N // 5

five = (five + 1) * 5 * five // 2 if five > 0 else 0

fifteen = N // 15

fifteen = (fifteen + 1) * 15 * fifteen // 2 if fifteen > 0 else 0

print((amount-three-five+fifteen))

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()))
# A = list(map(int, input().split()))
amount = (N + 1) * N // 2
three = N // 3
three = (three + 1) * 3 * three // 2 if three > 0 else 0
five = N // 5
five = (five + 1) * 5 * five // 2 if five > 0 else 0
fifteen = N // 15
fifteen = (fifteen + 1) * 15 * fifteen // 2 if fifteen > 0 else 0
print((amount - three - five + fifteen))

-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())) +# A = list(map(int, input().split())) +amount = (N + 1) * N // 2 +three = N // 3 +three = (three + 1) * 3 * three // 2 if three > 0 else 0 +five = N // 5 +five = (five + 1) * 5 * five // 2 if five > 0 else 0 +fifteen = N // 15 +fifteen = (fifteen + 1) * 15 * fifteen // 2 if fifteen > 0 else 0 +print((amount - three - five + fifteen))