N=int(eval(input()))

ans=0

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

    if not (i%3==0 or i%5==0):

        ans+=i

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

Fizz=list(range(3,N+1,3))

Buzz=list(range(5,N+1,5))

FizzBuzz=list(range(15,N+1,15))

ans=sum(range(1,N+1))-sum(Fizz)-sum(Buzz)+sum(FizzBuzz)

print(ans)

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

N = int(eval(input()))
Fizz = list(range(3, N + 1, 3))
Buzz = list(range(5, N + 1, 5))
FizzBuzz = list(range(15, N + 1, 15))
ans = sum(range(1, N + 1)) - sum(Fizz) - sum(Buzz) + sum(FizzBuzz)
print(ans)

-ans = 0 -for i in range(1, N + 1): -    if not (i % 3 == 0 or i % 5 == 0): -        ans += i +Fizz = list(range(3, N + 1, 3)) +Buzz = list(range(5, N + 1, 5)) +FizzBuzz = list(range(15, N + 1, 15)) +ans = sum(range(1, N + 1)) - sum(Fizz) - sum(Buzz) + sum(FizzBuzz)