import sys





def in_ctrl():

    _input = [_.rstrip() for _ in sys.stdin.readlines()]

    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

    N = int(_input[0])

    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    return N





def out_ctrl(s):

    print(s)





if __name__ == "__main__":

    N = in_ctrl()

    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

    cnt = 0

    for n in range(N+1):

        if n%3>0 and n%5>0:

            cnt += n

    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    out_ctrl(cnt)
from sys import stdin





def __sum(n):

    return n*(n+1)//2





if __name__ == "__main__":

    _in = [_.rstrip() for _ in stdin.readlines()]

    N = int(_in[0]) # type:int

    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

    cnt = __sum(N)-3*__sum(N//3)-5*__sum(N//5)+15*__sum(N//15)

    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    print(cnt)

import sys


def in_ctrl():
    _input = [_.rstrip() for _ in sys.stdin.readlines()]
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    N = int(_input[0])
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return N


def out_ctrl(s):
    print(s)


if __name__ == "__main__":
    N = in_ctrl()
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    for n in range(N + 1):
        if n % 3 > 0 and n % 5 > 0:
            cnt += n
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    out_ctrl(cnt)

from sys import stdin


def __sum(n):
    return n * (n + 1) // 2


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = __sum(N) - 3 * __sum(N // 3) - 5 * __sum(N // 5) + 15 * __sum(N // 15)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)

-import sys +from sys import stdin -def in_ctrl(): -    _input = [_.rstrip() for _ in sys.stdin.readlines()] -    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv -    N = int(_input[0]) -    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -    return N - - -def out_ctrl(s): -    print(s) +def __sum(n): +    return n * (n + 1) // 2 -    N = in_ctrl() +    _in = [_.rstrip() for _ in stdin.readlines()] +    N = int(_in[0])  # type:int -    cnt = 0 -    for n in range(N + 1): -        if n % 3 > 0 and n % 5 > 0: -            cnt += n +    cnt = __sum(N) - 3 * __sum(N // 3) - 5 * __sum(N // 5) + 15 * __sum(N // 15) -    out_ctrl(cnt) +    print(cnt)