def main():
    #N,K,C=map(int,input().split())
    #A=list(map(int,input().split()))
    S=input()
    S=int(S)
    ans=0
    for i in range(S+1):
        if i%3!=0 and i%5!=0:
            ans+=i
    print(ans)
    

main()
