n = int(eval(input()))



ans = 0

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

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

    continue

  else:

    ans += i



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



ans = 0

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

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

    continue

  else:

    ans += i



print(ans)
n = int(eval(input()))
ans = 0
for i in range(1, n + 1):
    if i % 15 == 0 or i % 5 == 0 or i % 3 == 0:
        continue
    else:
        ans += i
print(ans)

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

-    if i % 15 == 0 or i % 5 == 0 or i % 3 == 0: +    if i % 5 == 0 or i % 3 == 0: