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

total = int(1/2 * N *  (N+1))

wa3 =  (N//3 * (N//3 + 1)) // 2 * 3

wa5 =  (N//5 * (N//5 + 1)) // 2 * 5

wa15 =  (N//15 * (N//15 + 1)) // 2 * 15

print((total - wa3 - wa5 + wa15))
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()))
total = int(1 / 2 * N * (N + 1))
wa3 = (N // 3 * (N // 3 + 1)) // 2 * 3
wa5 = (N // 5 * (N // 5 + 1)) // 2 * 5
wa15 = (N // 15 * (N // 15 + 1)) // 2 * 15
print((total - wa3 - wa5 + wa15))

-ans = 0 -for i in range(1, N + 1): -    if i % 3 != 0 and i % 5 != 0: -        ans += i -print(ans) +total = int(1 / 2 * N * (N + 1)) +wa3 = (N // 3 * (N // 3 + 1)) // 2 * 3 +wa5 = (N // 5 * (N // 5 + 1)) // 2 * 5 +wa15 = (N // 15 * (N // 15 + 1)) // 2 * 15 +print((total - wa3 - wa5 + wa15))