def chop(n, base=1) count = 0 while n >= base break if n < base * 2 base <<= 1 count += 1 end count end n = gets.to_i count = chop(n) m = 1 << count count += 1 if n-m <= m and n-m > 0 puts count