Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        For i As Integer = N To 1 Step -1
            If Judge(i) Then
                WriteLine(i)
                Exit For
            End If
        Next
    End Sub

    Function Judge(N As Integer) As Boolean
        Do While N Mod 2 = 0 AndAlso N <> 0
            N \= 2
        Loop
        If N = 1 Then Return True
        Return False
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module
