n = int(input()) a = {i for i in range(2, n+1)} import math q=set() while True: p=sorted(list(a.difference(q)))[0] if p > int(math.sqrt(n)): break q.add(p) for i in range(2,n//p+1): a.discard(p*i) print(sum(a))