import scala.io.StdIn

import scala.annotation.tailrec

object Main extends App {
  val n = StdIn.readInt

  @tailrec
  def rec(acc:Int,num:Int):Int = {
    if((num&1) == 1) acc
    else {
      rec(acc+1,num>>1)
    }
  }
  val ans = (1 to n)./:(1,0)((max,i) => {
    val cnt = rec(0,i)
    if(max._2 < cnt) (i,cnt) else max
  })._1
  println(ans)
}