k=0 s=0 n=gets.to_i while s=n p ('1'*(i+1)+'0'*(s+k-i-n-1)+'1'*(k-i-1-(s+k-i-n-1))).to_i(2) exit else s+=k-2-i i+=1 end end p 2**k-1