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