n = gets.to_i
if n.even?
    puts 1
elsif n == 3
    puts 4
else
    x0 = n - 1
    y0 = 2
    k = 0
    loop do
        x = x0
        until x & 1 == 1
            k += 1
            x >>= 1
        end
        y = y0
        until y & 1 == 1
            k -= 1
            y >>= 1
        end
        break if k > 0
        x0 -= 2
        y0 += 2
    end
    puts y0
end

