n=gets.to_i;p (0..n.bit_length).map{|i|x=n>>i;(x/2).to_s(2).count(?1)+x&1}.max