-module('Main').
-export([main/1]).

main(_) ->
    {ok, [N]} = io:fread("", "~d"),
    {_Max, MaxN} = lists:last(lists:keysort(1,
                                           lists:map(fun(X) ->
                                                             Most = divideBy2(X),
                                                             {Most, X}
                                                     end,
                                                     lists:seq(1, N)))),
    io:format("~p~n", [MaxN]),
    halt().


divideBy2(N) ->
    divideBy2(N, 0).
divideBy2(1, C) ->
    C;
divideBy2(N, C) when N rem 2 =:= 0->
    NewN = N div 2,
    divideBy2(NewN, C + 1);
divideBy2(_N, C) ->
    C.

