N = int(eval(input()))

total = 0

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

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

    total =  total + i

print(total)

N = int(eval(input()))

total = 0

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

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

    total += i

print(total)

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

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

-        total = total + i +        total += i