#! /usr/bin/env python3



from fractions import gcd

from collections import Counter, deque, defaultdict

from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge

from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort

from itertools import accumulate, product, permutations, combinations, combinations_with_replacement



N = int(eval(input()))

ret = 0

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

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

        continue

    ret += i

print(ret)
#! /usr/bin/env python3



from fractions import gcd

from collections import Counter, deque, defaultdict

from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge

from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort

from itertools import accumulate, product, permutations, combinations, combinations_with_replacement



N = int(eval(input()))

ret = sum([i for i in range(1, N+1) if not (i % 3 == 0 or i % 5 == 0)])

print(ret)
#! /usr/bin/env python3
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import (
    accumulate,
    product,
    permutations,
    combinations,
    combinations_with_replacement,
)

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

#! /usr/bin/env python3
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import (
    accumulate,
    product,
    permutations,
    combinations,
    combinations_with_replacement,
)

N = int(eval(input()))
ret = sum([i for i in range(1, N + 1) if not (i % 3 == 0 or i % 5 == 0)])
print(ret)

-ret = 0 -for i in range(1, N + 1): -    if i % 3 == 0 or i % 5 == 0: -        continue -    ret += i +ret = sum([i for i in range(1, N + 1) if not (i % 3 == 0 or i % 5 == 0)])