import sys
#sys.exit()
#sorted( ,reverse=True)
N =  int(input())
#S,T = map(int, input().split())
#A = list(map(int, input().split()))
#print(N)
#print(S,T)
#print(A)
cnt = 0
a = N//3
b = N//5
for i in range(N+1):
    if i%3 !=0 and i%5 != 0: 
        cnt += i
print(cnt)