N = int(eval(input()))



a = [0] * N



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

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

        pass

    elif i%3 == 0:

        pass

    elif i%5 == 0:

        pass

    else:

        a[i-1] = i



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

ans = 0



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

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

    pass

  elif i%3==0:

    pass

  elif i%5==0:

    pass

  else:

    ans += i



print(ans)

  
N = int(eval(input()))
a = [0] * N
for i in range(1, N + 1):
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        a[i - 1] = i
print((sum(a)))

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

-a = [0] * N +ans = 0 -        a[i - 1] = i -print((sum(a))) +        ans += i +print(ans)