N = int(eval(input()))  #スペース抜きの複数行,１文字ずつ

 

A = []

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

  if i % 3 == 0:

    A.append(0)

  elif i % 5 == 0:

    A.append(0)

  else:

    A.append(i)



print((sum(A)))
N = int(eval(input()))



sum = 0

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

    if i % 3 == 0:

        continue

    elif i % 5 == 0:

        continue

    else:

        sum += i



print(sum)
N = int(eval(input()))  # スペース抜きの複数行,１文字ずつ
A = []
for i in range(1, N + 1):
    if i % 3 == 0:
        A.append(0)
    elif i % 5 == 0:
        A.append(0)
    else:
        A.append(i)
print((sum(A)))

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

-N = int(eval(input()))  # スペース抜きの複数行,１文字ずつ -A = [] +N = int(eval(input())) +sum = 0 -        A.append(0) +        continue -        A.append(0) +        continue -        A.append(i) -print((sum(A))) +        sum += i +print(sum)