x = int(eval(input()))

ans = 0



for i in range(x+1):

  if i % 15 == 0 :

    pass

  elif i % 3 == 0:

    pass

  elif i % 5 == 0:

    pass

  else:

    ans += i



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

ans = 0



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

  if i % 3 != 0 and i % 5 != 0:

    ans += i

print(ans)
x = int(eval(input()))
ans = 0
for i in range(x + 1):
    if i % 15 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        ans += i
print(ans)

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

-for i in range(x + 1): -    if i % 15 == 0: -        pass -    elif i % 3 == 0: -        pass -    elif i % 5 == 0: -        pass -    else: +for i in range(1, x + 1): +    if i % 3 != 0 and i % 5 != 0: