n = int(eval(input()))

totsum = 0

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

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

    totsum+=num

    

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

ans = 0

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

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

        pass

    else:

        ans += i

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

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

-totsum = 0 -for num in range(1, n + 1): -    if num % 3 != 0 and num % 5 != 0: -        totsum += num -print(totsum) +ans = 0 +for i in range(1, n + 1): +    if i % 3 == 0 or i % 5 == 0: +        pass +    else: +        ans += i +print(ans)