n=gets.to_i;p n.times.map{|i|n>>i-(i..n).reduce(0){|s,j|s+(n>>i+1)}}.max