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