i = int(input())
ans = []
for ii in range(i+1):
    if ii % 3 == 0:
        ans.append(0)
    elif ii % 5 == 0:
        ans.append(0)
    elif ii % 15 == 0:
        ans.append(0)
    else:
        ans.append(ii)
print(sum(ans))