count=0

N=int(eval(input()))

for i in range(N):

	if (i+1)%3==0 and (i+1)%5==0:

		continue

	elif (i+1)%3==0:

		continue

	elif (i+1)%5==0:

		continue

	else:

		count+=(i+1)

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

ans=0

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

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

	else:

		ans+=i

print(ans)
count = 0
N = int(eval(input()))
for i in range(N):
    if (i + 1) % 3 == 0 and (i + 1) % 5 == 0:
        continue
    elif (i + 1) % 3 == 0:
        continue
    elif (i + 1) % 5 == 0:
        continue
    else:
        count += i + 1
print(count)

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

-count = 0 -for i in range(N): -    if (i + 1) % 3 == 0 and (i + 1) % 5 == 0: -        continue -    elif (i + 1) % 3 == 0: -        continue -    elif (i + 1) % 5 == 0: +ans = 0 +for i in range(1, N + 1): +    if i % 3 == 0 or i % 5 == 0: -        count += i + 1 -print(count) +        ans += i +print(ans)