A=int(input())
three=int(A/3)
five=int(A/5)
fif=int(A/15)
count=0
for i in range(A+1):
    count+=i

if A>=15:
    final=int(count-(1/2*three*(3+three*3))-(1/2*five*(5+five*5))+(1/2*fif*(15+fif*15)))
    print(final)

elif 5<=A<15:
    final=int(count-(1/2*three*(3+three*3))-(1/2*five*(5+five*5)))
    print(final)

elif 3<=A<5:
    final=int(count-(1/2*three*(3+three*3)))
    print(final)

else:
    print(count)