D=int(input()) for i in range(D//2,10**20): d=i while i>1: d+=i//2 i//=2 if d==D: print(i) exit()