k=gets.to_i (0..2**30).each{ |s| d = s.to_s(2) a = d.count( "0" ) b = d.count( "1" ) if 2**a*b*~-b/2==k p a+b puts d exit end }