N = int(input()) a = 1 while a < N: for b in bin(a): if b == "1": a += 1 print(a)