import sys
import numpy as np

n=int(sys.stdin.readline())
#n,k=map(int,sys.stdin.readline().split())
#a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')

ans=0
for i in range(1,n+1):
    if i%3!=0 and i%5!=0:
        ans+=i

print(ans)
