N = int(eval(input()))

ans = 0

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

    if i%3 and i%5:

        ans += i



print(ans)
N = int(eval(input()))

N3 = N//3

N5 = N//5

N15 = N//15



ans = N*(N+1)/2 - 3*N3*(N3+1)/2 -5*N5*(N5+1)/2 + 15*N15*(N15+1)/2



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

N = int(eval(input()))
N3 = N // 3
N5 = N // 5
N15 = N // 15
ans = (
    N * (N + 1) / 2
    - 3 * N3 * (N3 + 1) / 2
    - 5 * N5 * (N5 + 1) / 2
    + 15 * N15 * (N15 + 1) / 2
)
print((int(ans)))

-ans = 0 -for i in range(1, N + 1): -    if i % 3 and i % 5: -        ans += i -print(ans) +N3 = N // 3 +N5 = N // 5 +N15 = N // 15 +ans = ( +    N * (N + 1) / 2 +    - 3 * N3 * (N3 + 1) / 2 +    - 5 * N5 * (N5 + 1) / 2 +    + 15 * N15 * (N15 + 1) / 2 +) +print((int(ans)))