n = int(input()) searchlist = list(range(2,n+1)) primelist = [] while searchlist[0]**2 <= n: primelist.append(searchlist[0]) searchlist = [i for i in searchlist if i%primelist[-1]!=0] primelist.extend(searchlist) print(sum(primelist))