biscuit = gets.to_i n = 0 while 2**n < biscuit do #maxの枚数を超えるまで倍々 n += 1 end if 2**n == biscuit then #初期値からピッタリで終わる時 puts n elsif (biscuit - 2**(n-1)) == 1 #2の累乗より1多い時 puts n elsif (biscuit - 2**(n-1)) == 2 #2の累乗より2多い時 puts n + 1 elsif ((biscuit - 2**(n-1)) % 2) == 0 #初期値からmaxの枚数を超えない回数で残りの枚数が偶数の時 puts n elsif ((biscuit - 2**(n-1)) % 2) == 1 #初期値からmaxの枚数を超えない回数で残りの枚数が奇数の時 puts n + 1 end