n=int(input()) s=[x for x in range(1,n*2) if x&n==x] l=len(s) print(sorted(s)[(l+1)//2-1])