(* O(n log n) *)
let n = read_int () in
let rec count c m = if m mod 2 = 1 then c else count (c + 1) (m / 2) in
let counts = Array.init n @@ fun i -> i + 1, count 0 @@ i + 1 in
let max (x1, c1) (x2, c2) = if c1 < c2 then x2, c2 else x1, c1 in
Array.fold_left max (1, 0) counts |> fst |> Printf.printf "%d\n"