N=int(eval(input()))



total=0



for i in range(N+1):

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

    continue

  

  else:

    total+=i



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



total=0



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

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

    pass

  else:

    total +=i



print(total)
N = int(eval(input()))
total = 0
for i in range(N + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        total += i
print(total)

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

-for i in range(N + 1): +for i in range(1, N + 1): -        continue +        pass