n = int(eval(input()))



res = []

for i in range(n + 1):

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

        res.append(i)

print((sum(res)))
import sys



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    n = int(eval(input()))



    res = 0

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

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

            continue

        else:

            res += i



    print(res)





if __name__ == '__main__':

    resolve()

n = int(eval(input()))
res = []
for i in range(n + 1):
    if i % 3 != 0 and i % 5 != 0:
        res.append(i)
print((sum(res)))

import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n = int(eval(input()))
    res = 0
    for i in range(1, n + 1):
        if i % 3 == 0 or i % 5 == 0:
            continue
        else:
            res += i
    print(res)


if __name__ == "__main__":
    resolve()

-n = int(eval(input())) -res = [] -for i in range(n + 1): -    if i % 3 != 0 and i % 5 != 0: -        res.append(i) -print((sum(res))) +import sys + +sys.setrecursionlimit(10**7) +f_inf = float("inf") +mod = 10**9 + 7 + + +def resolve(): +    n = int(eval(input())) +    res = 0 +    for i in range(1, n + 1): +        if i % 3 == 0 or i % 5 == 0: +            continue +        else: +            res += i +    print(res) + + +if __name__ == "__main__": +    resolve()