N=int(input()) N=bin(N) cnt=0 for i in range(len(N)): if N[i]=="1": cnt+=1 print(2**cnt-2)