K = gets.to_i case K when 0 p 1, 0 when 1 p 2, 1, 1 when 2 p 3, 0, 1, 1 else s = 0 a = (1..30).map{|j| s += j } a.each.with_index(2){|b, i| n = Math.log2(K / b).floor if b * 2**n == K p i + n n.times{p 0} i.times{p 1} exit end } end