# _*_ coding:utf-8 _*_

#  Atcoder_Beginners_Contest068-B

#  https://beta.atcoder.jp/contests/abc068/tasks/abc068_b





def breakNumber(pint):



	numArray = [i for i in range(1,pint+1)]

	i = 0



	while i < pint :

		devCount=0

		while numArray[i] % 2 == 0:

			devCount = devCount+1

			numArray[i] = numArray[i] // 2

		numArray[i] = devCount

		i=i+1



	maxDevLabel = -1

	maxDevNumber = -1

	i = 0

	while i < pint :

		if maxDevNumber < numArray[i] :

			maxDevNumber = numArray[i]

			maxDevLabel = i

		i = i + 1



	answer = maxDevLabel+1

	return answer





if __name__ == '__main__':

	inputNum = int(eval(input()))

	ans=breakNumber(inputNum)

	print(ans)



# Problem https://atcoder.jp/contests/abc068/tasks/abc068_b

# Python 1st Try





def solver(givenNum):



    answer = 1

    counter = 0

    rangeNum = list(range(0, givenNum))

    eachCount = [0] * givenNum

    for j in rangeNum:

        oneCount = 0

        nowNumber = j + 1

        while True:

            if nowNumber % 2 == 0:

                oneCount = oneCount + 1

                nowNumber = nowNumber / 2

            else:

                break

        eachCount[j] = oneCount

#    print(eachCount)

    for j in rangeNum:

        if counter <= eachCount[j]:

            counter = eachCount[j]

            answer = j + 1

    return answer





if __name__ == "__main__":

    print((solver(int(eval(input())))))

# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest068-B
#  https://beta.atcoder.jp/contests/abc068/tasks/abc068_b
def breakNumber(pint):
    numArray = [i for i in range(1, pint + 1)]
    i = 0
    while i < pint:
        devCount = 0
        while numArray[i] % 2 == 0:
            devCount = devCount + 1
            numArray[i] = numArray[i] // 2
        numArray[i] = devCount
        i = i + 1
    maxDevLabel = -1
    maxDevNumber = -1
    i = 0
    while i < pint:
        if maxDevNumber < numArray[i]:
            maxDevNumber = numArray[i]
            maxDevLabel = i
        i = i + 1
    answer = maxDevLabel + 1
    return answer


if __name__ == "__main__":
    inputNum = int(eval(input()))
    ans = breakNumber(inputNum)
    print(ans)

# Problem https://atcoder.jp/contests/abc068/tasks/abc068_b
# Python 1st Try
def solver(givenNum):
    answer = 1
    counter = 0
    rangeNum = list(range(0, givenNum))
    eachCount = [0] * givenNum
    for j in rangeNum:
        oneCount = 0
        nowNumber = j + 1
        while True:
            if nowNumber % 2 == 0:
                oneCount = oneCount + 1
                nowNumber = nowNumber / 2
            else:
                break
        eachCount[j] = oneCount
    #    print(eachCount)
    for j in rangeNum:
        if counter <= eachCount[j]:
            counter = eachCount[j]
            answer = j + 1
    return answer


if __name__ == "__main__":
    print((solver(int(eval(input())))))

-# _*_ coding:utf-8 _*_ -#  Atcoder_Beginners_Contest068-B -#  https://beta.atcoder.jp/contests/abc068/tasks/abc068_b -def breakNumber(pint): -    numArray = [i for i in range(1, pint + 1)] -    i = 0 -    while i < pint: -        devCount = 0 -        while numArray[i] % 2 == 0: -            devCount = devCount + 1 -            numArray[i] = numArray[i] // 2 -        numArray[i] = devCount -        i = i + 1 -    maxDevLabel = -1 -    maxDevNumber = -1 -    i = 0 -    while i < pint: -        if maxDevNumber < numArray[i]: -            maxDevNumber = numArray[i] -            maxDevLabel = i -        i = i + 1 -    answer = maxDevLabel + 1 +# Problem https://atcoder.jp/contests/abc068/tasks/abc068_b +# Python 1st Try +def solver(givenNum): +    answer = 1 +    counter = 0 +    rangeNum = list(range(0, givenNum)) +    eachCount = [0] * givenNum +    for j in rangeNum: +        oneCount = 0 +        nowNumber = j + 1 +        while True: +            if nowNumber % 2 == 0: +                oneCount = oneCount + 1 +                nowNumber = nowNumber / 2 +            else: +                break +        eachCount[j] = oneCount +    #    print(eachCount) +    for j in rangeNum: +        if counter <= eachCount[j]: +            counter = eachCount[j] +            answer = j + 1 -    inputNum = int(eval(input())) -    ans = breakNumber(inputNum) -    print(ans) +    print((solver(int(eval(input())))))