import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    a = int(input())

    count = 0

    for i in range(1,a+1):
        if i %3 > 0 and i % 5 >0:
            count += i
    print(count)