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

A = []



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

    if i % 15 == 0:

        A.append(0)

    elif i % 3 == 0:

        A.append(0)

    elif i % 5 == 0:

        A.append(0)

    else:

        A.append(i)



print((sum(A)))
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()))  # スペース抜きの複数行,１文字ずつ
A = []
for i in range(1, n + 1):
    if i % 15 == 0:
        A.append(0)
    elif i % 3 == 0:
        A.append(0)
    elif i % 5 == 0:
        A.append(0)
    else:
        A.append(i)
print((sum(A)))

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()))  # スペース抜きの複数行,１文字ずつ +N = int(eval(input()))  # スペース抜きの複数行,１文字ずつ -for i in range(1, n + 1): -    if i % 15 == 0: -        A.append(0) -    elif i % 3 == 0: +for i in range(1, N + 1): +    if i % 3 == 0: