N=int(input()) def calc(N): if N==0: return 1 if N%2==1: return calc(N//2)*2 else: return calc(N//2) print(calc(N)-2)