Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautiful iff its binary representation consists of k + 1 consecutive ones, and then k consecutive zeroes.

Some examples of beautiful numbers:   1_2 (1_10);  110_2 (6_10);  1111000_2 (120_10);  111110000_2 (496_10). 

More formally, the number is beautiful iff there exists some positive integer k such that the number is equal to (2^{k} - 1) * (2^{k} - 1).

Luba has got an integer number n, and she wants to find its greatest beautiful divisor. Help her to find it!


-----Input-----

The only line of input contains one number n (1 ≤ n ≤ 10^5) — the number Luba has got.


-----Output-----

Output one number — the greatest beautiful divisor of Luba's number. It is obvious that the answer always exists.


-----Examples-----
Input
3

Output
1

Input
992

Output
496

Difficulty: EASY

Solutions:
n = int(input())
a = []
for i in range(1, 13, 1):
	temp = (2 ** i - 1) * 2 ** (i - 1)
	if n % temp == 0:
		a.append(temp)
print(max(a))


def beauty_del(n):
	numbers = [1, 6, 28, 120, 496, 2016, 8128, 32640]
	numbers.reverse()
	for i in range(len(numbers)):
		if n % numbers[i] == 0:
			return numbers[i]
n = int(input())
print(beauty_del(n))


n = int(input())
ls = []
k = 1
z = 0
while z <= n:
	z = (2 ** k - 1) * 2 ** (k - 1)
	if z > n:
		break
	ls.append(z)
	k += 1
t = len(ls) - 1
while t >= 0:
	if n % ls[t] == 0:
		res = ls[t]
		break
	else:
		t -= 1
print(res)


def main():
	n = int(input())
	for p in (32640, 8128, 2016, 496, 120, 28, 6, 1):
		if not n % p:
			break
	print(p)
main()


n = int(input())
beautiful = []
k = 1
while True:
	num = (2 ** k - 1) * 2 ** (k - 1)
	if num > 10 ** 5:
		break
	beautiful.append(num)
	k += 1
for x in beautiful[::-1]:
	if n % x == 0:
		print(x)
		break


k = 1
n = int(input())
q = []
while (pow(2, k) - 1) * pow(2, k - 1) <= n:
	q.append((pow(2, k) - 1) * pow(2, k - 1))
	k += 1
for i in range(len(q) - 1, -1, -1):
	if n % q[i] == 0:
		print(q[i])
		break


a = int(input())
lista = [(2 ** x - 1) * 2 ** (x - 1) for x in range(1, 9)]
for i in range(len(lista) - 1, -1, -1):
	if a % lista[i] == 0:
		print(lista[i])
		break


n = int(input())
p = []
for i in range(1, n + 1):
	if n % i == 0:
		p += [i]
s = []
for i in p:
	k = bin(i)
	k = k[2:]
	k = str(k)
	a = len(k)
	k = k.lstrip('1')
	b = len(k)
	a = a - b
	if a == b + 1 and k.count('1') == 0:
		s += [i]
print(max(s))


import math

def IsBeautiful(n):
	binary = '{0:b}'.format(n)
	ones = ''
	zeroes = ''
	for c in binary:
		if c == '1':
			ones += '1'
		else:
			zeroes += '0'
	return len(ones) == len(zeroes) + 1 and ones + zeroes == binary

def main():
	n = int(input().strip())
	for i in reversed(range(1, n + 1)):
		if n / i % 1 == 0 and IsBeautiful(i):
			print(i)
			return
main()


n = int(input())
count = 1
for i in range(2, 16):
	if n % (((1 << i) - 1) * (1 << i - 1)) == 0:
		count = ((1 << i) - 1) * (1 << i - 1)
print(count)


import sys
input = sys.stdin.readline

def prog():
	n = int(input())
	best = 1
	curr = 1
	i = 1
	while curr <= n:
		curr = curr * 2 + (1 << 2 * i)
		i += 1
		if n % curr == 0:
			best = curr
	print(best)
prog()


import sys
l = [1, 6, 28, 120, 496, 2016, 8128, 32640]
n = int(input())
for i in reversed(l):
	if n % i == 0:
		print(i)
		sys.exit(0)


def minus(f):
	k = ''
	for i in range(len(f) - 2):
		if i <= (len(f) - 2) // 2:
			k += '1'
		else:
			k += '0'
	return k
a = int(input())
t = ''
h = str(bin(a))
for i in range(len(h) - 2):
	t += h[2 + i]
if len(t) % 2 == 0:
	kek = len(t) // 2
	tr = len(t) - 1
else:
	kek = len(t) // 2 + 1
	tr = len(t)
e = ''
for i in range(tr):
	if i <= tr // 2:
		e += '1'
	else:
		e += '0'
r = 0
for i in range(kek):
	if a % int(e, 2) == 0 and r == 0:
		print(int(e, 2))
		r = 1
	elif r == 0:
		e = minus(e)


import math

def proB(n):
	lst = []
	for i in range(1, n + 1):
		if n % i == 0:
			lst.append(i)
	k = int(math.log2(100000.0))
	for j in lst:
		for i in range(k, 0, -1):
			if j == 2 ** (i - 1) * (2 ** i - 1):
				maxi = j
	return maxi
n = int(input())
print(proB(n))


from sys import stdin

def iinput():
	return int(stdin.readline())

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))

def f(k):
	return (2 ** k - 1) * 2 ** (k - 1)
p = [f(k) for k in range(1, 12)]
n = iinput()
for e in p[::-1]:
	if n % e == 0:
		print(e)
		break


n = int(input())
for k in range(10, 0, -1):
	if n % ((2 ** k - 1) * 2 ** (k - 1)) == 0:
		print((2 ** k - 1) * 2 ** (k - 1))
		quit()


n = int(input())
max_x = 1
x = 1
has = (2 ** x - 1) * 2 ** (x - 1)
while has <= n:
	if n % has == 0:
		max_x = x
	x += 1
	has = (2 ** x - 1) * 2 ** (x - 1)
print((2 ** max_x - 1) * 2 ** (max_x - 1))


n = int(input())

def isp(d):
	d1 = str(bin(d))[1:]
	c1 = d1.count('1')
	c2 = d1.count('0')
	c3 = d1.count('01')
	c4 = d1.count('10')
	return c1 - c2 == 1 and c3 + c4 == 1
ans = 1
for d in range(1, int(n ** 0.5 + 1)):
	if n // d != d and n % d == 0 and isp(n // d):
		ans = max(ans, n // d)
	if n % d == 0 and isp(d):
		ans = max(ans, d)
print(ans)


n = int(input())
a = []
tmp = 0
k = 1
while tmp * 2 < n:
	tmp = (2 ** k - 1) * 2 ** (k - 1)
	a.append(tmp)
	k += 1
for i in range(len(a) - 1, -1, -1):
	if n % a[i] == 0:
		print(a[i])
		return


(n, c) = (int(input()), 1)
for i in range(1, 9):
	z = (2 ** i - 1) * 2 ** (i - 1)
	if n % z == 0:
		c = z
print(c)


dict = {1}
dict = list(dict)
cur = 1
for i in range(15):
	cur *= 4
	cur += 2 ** (i + 1)
	dict.append(cur)
n = input()
n = int(n)
ans = 1
for x in dict:
	if n % x == 0:
		ans = x
	else:
		pass
print(ans)


__author__ = 'tiffanislutsky'

def ans(x):
	n = [32640, 8128, 2016, 496, 120, 28, 6]
	for a in n:
		if x % a == 0:
			return a
	return 1
x = int(input())
print(ans(x))


n = int(input())
for k in [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]:
	d = (2 ** (k + 1) - 1) * 2 ** k
	if n % d == 0:
		print(d)
		break


input_data = int(input())
n = 0
divinded = []
k = 0
while n < 10 ** 5:
	n = (2 ** k - 1) * 2 ** (k - 1)
	k = k + 1
	if n == 0:
		continue
	divinded.append(n)
cur_max = 0
for i in range(len(divinded)):
	if input_data % divinded[i] == 0:
		cur_max = i
print(divinded[cur_max])


a = input()
b = 1
c = 1
num = []
while b <= 100000:
	b = (2 ** c - 1) * 2 ** (c - 1)
	num.append(b)
	c = c + 1
num.pop(len(num) - 1)
temp = 0
for k in range(len(num)):
	if int(a) % num[k] == 0:
		temp = num[k]
print(temp)


n = int(input())
divisor = 1
flag = True
k = 2
while flag:
	u = (2 ** k - 1) * 2 ** (k - 1)
	if n % u == 0:
		divisor = u
	if n <= u:
		flag = False
	k += 1
print(divisor)


def divisores(numero):
	divisor = 0
	if numero % 2 == 0:
		iterar = numero / 2
	else:
		iterar = (numero - 1) / 2
	f = []
	for i in range(1, int(iterar) + 1):
		if numero % i == 0:
			aux = numero / i
			if aux != divisor:
				divisor = aux
			if i == iterar:
				f.append(int(divisor))
			else:
				f.append(divisor)
	f.append(1)
	return f

def binarizar(decimal):
	binario = ''
	while decimal // 2 != 0:
		binario = str(decimal % 2) + binario
		decimal = decimal // 2
	return str(decimal) + binario

def esbeatiful(h):
	contu = 0
	contz = 0
	if len(h) % 2 != 0:
		if h[:len(h) // 2 + 1].count('1') == len(h) // 2 + 1:
			contu = len(h) // 2 + 1
		if h[len(h) // 2:].count('0') == len(h) // 2:
			contz = len(h) // 2
		if contu == contz + 1:
			return 1
		else:
			return 0
numero = int(input())
a = divisores(numero)
a.insert(0, numero)
for x in range(1, len(a)):
	h = binarizar(int(a[x]))
	if esbeatiful(h):
		print(int(a[x]))
		break


n = int(input())

def solve_two(n):
	k = 1
	n1 = n
	ans = 1
	temp = 1
	while n1 % 2 == 0:
		temp = 2 ** k
		temp = temp * (2 * temp - 1)
		if n % temp == 0:
			ans = temp
		n1 = n1 / 2
		k += 1
	print(ans)
	return
solve_two(n)


n = int(input())
beut = []
for i in range(10):
	nn = pow(2, 2 * i - 1) - pow(2, i - 1)
	beut.append(nn)
f = -1
for k in range(len(beut) - 1, -1, -1):
	if n % beut[k] == 0:
		print(beut[k])
		break


n = int(input())
i = '110'
p = 1
while int(i, 2) <= n:
	if not n % int(i, 2):
		p = int(i, 2)
	i = '1' + i + '0'
print(p)


def f(num):
	num = bin(num)
	num = num[2:]
	if num == '1':
		return True
	changeCount = 0
	(oneCount, zeroCount) = (0, 0)
	var = len(num) - 1
	for i in range(len(num)):
		if num[i] == '1':
			oneCount += 1
		if num[i] == '0':
			zeroCount += 1
		if i != var and num[i] != num[i + 1]:
			changeCount += 1
	if changeCount <= 1 and zeroCount + 1 == oneCount:
		return True
	else:
		return False
n = int(input())
x = n
n = range(n, 0, -1)
for i in n:
	if x % i == 0 and f(i):
		print(i)
		break


n = int(input())
exp = 1
t = 1
ans = 1
while t <= n:
	if n % t == 0:
		ans = t
	exp += 1
	t = (2 ** exp - 1) * 2 ** (exp - 1)
print(ans)


n = int(input())
t = 0
for i in range(17):
	if n % (2 ** i * (2 ** (i + 1) - 1)) == 0:
		t = i
print(2 ** t * (2 ** (t + 1) - 1))


k = int(input())
i = '1'
maximal = 0
for l in range(1000):
	if k % int(i, 2) == 0:
		maximal = int(i, 2)
	i = '1' + i + '0'
print(maximal)


n = int(input())
for i in range(8, -1, -1):
	b = (2 ** (i + 1) - 1) * 2 ** i
	if n % b == 0:
		print(b)
		exit()


class Solution(object):

	def __init__(self):
		self.solve()

	def next(self, type=int):
		temp = list(map(type, input().split()))
		return temp if len(temp) > 1 else temp[0]

	def solve(self):
		n = self.next()
		for i in range(20, 0, -1):
			div = (2 ** i - 1) * 2 ** (i - 1)
			if not n % div:
				print(div)
				break
Solution()


z = input
mod = 10 ** 9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)
n = int(z())
for i in range(n, 0, -1):
	if n % i != 0:
		continue
	p = bin(i)
	p = p[2:]
	if len(p) % 2 != 0:
		hf = ceil(len(p) / 2)
		t = 0
		t1 = 0
		for ik in range(hf):
			if p[ik] == '1':
				t += 1
			if p[-1 - ik] == '0':
				t1 += 1
		if t - t1 == 1 and t + t1 == len(p):
			print(i)
			exit(0)


Input = lambda : map(int, input().split())

def cal(num):
	for k in range(1, 10):
		y = (int(pow(2, k)) - 1) * int(pow(2, k - 1))
		if y == num:
			return True
	return False

def divisor(n):
	yield n
	yield (n // 2)
	n //= 2
	while n != 0:
		n -= 1
		yield n
n = int(input())
for i in divisor(n):
	if n % i == 0:
		if cal(i):
			print(i)
			break


def check(x):
	for k in range(17):
		if x == (2 ** k - 1) * 2 ** (k - 1):
			return True
	return False
n = int(input())
ans = 0
for i in range(1, n + 1):
	if n % i == 0 and check(i):
		ans = max(ans, i)
print(ans)


def main():
	n = int(input())
	for i in range(n, 0, -1):
		if n % i == 0:
			d = str(bin(i))[2:]
			if len(d) % 2 != 0:
				if d.startswith('1' * (len(d) // 2 + 1)) and d.endswith('0' * (len(d) // 2)):
					print(i)
					return
main()


f = lambda : map(int, input().split())
n = int(input())
d = [2096128, 523776, 130816, 32640, 8128, 2016, 496, 120, 28, 6, 1]
for i in d:
	if n % i == 0:
		print(i, end=' ')
		break


n = int(input())
ans = 1
for i in range(1, 10):
	a = (2 ** i - 1) * 2 ** (i - 1)
	if n % a == 0:
		ans = a
print(ans)


n = int(input())
i = 1

def is_ok(x):
	k = 1
	while True:
		aim = ((1 << k) - 1) * (1 << k - 1)
		if aim == x:
			return True
		elif aim > x:
			break
		k += 1
	return False
res = 0
while i * i <= n:
	if n % i == 0:
		if is_ok(i):
			res = max(res, i)
		if is_ok(n // i):
			res = max(res, n // i)
	i += 1
print(res)


n = int(input())
if n % 32640 == 0:
	print('32640')
elif n % 8128 == 0:
	print('8128')
elif n % 2016 == 0:
	print('2016')
elif n % 496 == 0:
	print('496')
elif n % 120 == 0:
	print('120')
elif n % 28 == 0:
	print('28')
elif n % 6 == 0:
	print('6')
else:
	print('1')


n = int(input())
a = []
b = []
ans = 0
for i in range(8):
	if i == 0:
		a.append(1)
	a.append(a[-1] * 2)
	b.append((a[-1] - 1) * a[-2])
for j in range(8):
	if n % b[7 - j] == 0:
		print(b[7 - j])
		break


import sys
import math
BeauNums = []
bas = '1'
for i in range(0, 10):
	BeauNums.append(int(bas, 2))
	bas = '1' + bas + '0'
n = int(input())
for i in range(9, -1, -1):
	if n % BeauNums[i] == 0:
		print(BeauNums[i])
		exit()


from __future__ import division, print_function
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
import heapq
from math import ceil, floor, log, sqrt, factorial, pow, pi

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph():
	d = {}
	(v, e) = mi()
	for i in range(e):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d.keys():
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = {}
	for i in range(n):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
	return d
l = [1]
k = 2
int_max = 100000
y = 1
z = 1
x = 1
while x <= int_max:
	x = (pow(2, k) - 1) * pow(2, k - 1)
	l.append(int(x))
	k += 1
n = ii()
if n in l:
	print(n)
else:
	m = 0
	for i in range(len(l)):
		if n % l[i] == 0 and l[i] > m:
			m = l[i]
	print(m)


from collections import Counter, defaultdict
import itertools
import sys

def main():
	n = int(input())
	ans = 1
	for k in range(1, 10):
		v = ((1 << k) - 1) * (1 << k - 1)
		if n % v == 0:
			ans = v
	print(ans)
main()


n = int(input())
c = 1
k = 1
while k < 20:
	x = (2 ** k - 1) * 2 ** (k - 1)
	if n % x == 0:
		c = x
	k += 1
print(c)


import sys
n = int(input())
for i in range(n + 1):
	k = 1
	while (2 ** k - 1) * 2 ** (k - 1) < n - i:
		k += 1
	if (2 ** k - 1) * 2 ** (k - 1) == n - i and n % ((2 ** k - 1) * 2 ** (k - 1)) == 0:
		print(n - i)
		sys.exit()


def beautiful_num():
	start = 0
	while True:
		start += 1
		yield ((2 ** start - 1) * 2 ** (start - 1))
num = int(input())
current_greatest = 0
for x in beautiful_num():
	if x > num:
		break
	elif num % x == 0:
		current_greatest = x
print(current_greatest)


res = 0

def judge(x):
	buf = []
	while x:
		buf.append(x % 2)
		x >>= 1
	n = len(buf)
	if n % 2 == 0:
		return False
	else:
		k = (n - 1) // 2
		bef = buf[0:k]
		nxt = buf[k:]
		for x in bef:
			if x == 1:
				return False
		for x in nxt:
			if x == 0:
				return False
	return True
n = int(input())
for i in range(1, n + 1):
	if judge(i) and n % i == 0 and (i > res):
		res = i
print(res)


K = int(input())
if K <= 3 or (K % 2 != 0 and K % 3 != 0):
	print(1)
	exit()
i = K
while i >= 1:
	if K % i == 0:
		Binary = bin(i)[2:]
		if '01' not in str(Binary) and Binary.count('0') - Binary.count('1') == -1:
			print(i)
			exit()
	i -= 1


import math
n = int(input())
d = 1
for x in range(1, int(math.sqrt(n)) + 1):
	if n % x == 0:
		if x % 2 == 0:
			k = 0
			m = x
			while m % 2 == 0:
				m //= 2
				k += 1
			if 2 ** k * (2 ** (k + 1) - 1) == x:
				d = max(x, d)
		x1 = n // x
		if x1 % 2 == 0:
			k = 0
			m = x1
			while m % 2 == 0:
				m //= 2
				k += 1
			if 2 ** k * (2 ** (k + 1) - 1) == x1:
				d = max(x1, d)
print(d)


(Beautiful, n, i) = ([1, 6, 28, 120, 496, 2016, 8128, 32640], int(input()), 7)
while n % Beautiful[i]:
	i -= 1
print(Beautiful[i])


import math as mt
n = int(input())
L = []
k = 1
while 2 ** (k - 1) * (2 ** k - 1) <= n:
	L.append(2 ** (k - 1) * (2 ** k - 1))
	k += 1
L1 = []
for i in L:
	if n % i == 0:
		L1.append(i)
print(max(L1))


import sys
n = int(sys.stdin.readline())
k = 1
beautnums = [0]
num_b = 1
while num_b < 10 ** 5:
	num_b = (2 ** k - 1) * 2 ** (k - 1)
	beautnums.append(num_b)
	k += 1
for i in reversed(range(0, len(beautnums))):
	if n % beautnums[i] == 0:
		print(beautnums[i])
		sys.exit(0)


n = int(input())
p = []
o = [1, 6, 28, 120, 496, 2016, 8128, 32640]
for i in range(len(o)):
	if n % o[i] == 0:
		p.append(o[i])
print(max(p))


n = int(input())

def p(a):
	t = 1
	for i in range(a):
		t *= 2
	return t
last = 1
k = 1
while True:
	k = k + 1
	now = (p(k) - 1) * p(k - 1)
	if now > n:
		break
	if n % now == 0:
		last = now
print(last)


__author__ = 'NIORLYS'
import math
n = int(input())
k = int(math.log(math.sqrt(1 + 8 * n), 2))
answer = None
for i in range(k, 0, -1):
	if n % ((2 ** i - 1) * 2 ** (i - 1)) == 0:
		answer = (2 ** i - 1) * 2 ** (i - 1)
		break
print(answer)


n = int(input())
log2 = 0
nn = n
while nn % 2 == 0:
	log2 += 1
	nn //= 2
for i in range(log2, -1, -1):
	x = 2 ** (i + 1) - 1
	if n % x == 0:
		print(x * (x + 1) // 2)
		break


n = int(input())
cnt = 0
for i in range(1, 50):
	if n % ((2 ** i - 1) * 2 ** (i - 1)) == 0:
		cnt = max(cnt, (2 ** i - 1) * 2 ** (i - 1))
print(cnt)


n = int(input())
a = [1, 6, 28, 120, 496, 2016, 8128, 32640]
maxi = 0
for i in range(0, len(a)):
	if n % a[i] == 0:
		maxi = a[i]
print(maxi)


x = int(input())
maximum = 1
for i in range(1, x):
	k = (2 ** i - 1) * 2 ** (i - 1)
	if x % k == 0:
		maximum = k
	if k > x:
		print(maximum)
		exit()
print(maximum)
exit()


n = int(input())
for k in range(9):
	d = 2 * 2 ** k - 1 << k
	if n % d == 0:
		ans = d
print(ans)


def find_beautifuls():
	beautiful_numbers = {}
	zeros = 0
	while zeros < 9:
		current = 1
		for _ in range(zeros):
			current <<= 1
			current += 1
		for _ in range(zeros):
			current <<= 1
		beautiful_numbers[current] = True
		zeros += 1
	return beautiful_numbers

def solution(n):
	beautiful_numbers = find_beautifuls()
	dividers = [i for i in range(n, 0, -1) if n % i == 0]
	for i in dividers:
		if i in beautiful_numbers:
			return i
	return 1
n = int(input())
print(solution(n))


def kek(v, ost):
	k = v + 1
	if ost % (2 ** k - 1) == 0:
		return True
	else:
		return False
n = int(input())
tmp = n
v = 0
while tmp % 2 == 0:
	v += 1
	tmp //= 2
m = tmp
for i in reversed(range(v + 1)):
	if i == 0:
		print(1)
		exit(0)
	if kek(i, m):
		k = i + 1
		print(2 ** (k - 1) * (2 ** k - 1))
		exit(0)


l = [1, 6, 28, 120, 496, 2016, 8128, 32640]
n = int(input())
for i in range(len(l) - 1, -1, -1):
	if n % l[i] == 0:
		print(l[i])
		break


n = int(input())
k = 1
while n & 1 == 0:
	k += 1
	n >>= 1
while k > 0:
	d = (1 << k) - 1
	if n % d == 0:
		print(d << k - 1)
		break
	k -= 1


n = int(input())
s = '1'
a = []
while len(s) <= 17:
	a.append(int(s, 2))
	s = '1' + s + '0'
sw = []
for i in range(1, int(n ** 0.5) + 1):
	if n % i == 0:
		if i in a:
			sw.append(i)
		if n // i in a:
			sw.append(n // i)
print(max(sw))


def code9():
	n = int(input())
	c = 0
	a = []
	k = 0
	while c <= 10 ** 5 + 1:
		c = (2 ** k - 1) * 2 ** (k - 1)
		k += 1
		a.append(c)
	for i in range(n, 0, -1):
		if n % i == 0 and i in a:
			print(i)
			break
code9()


a = [1]
k = 1
ans = []
while max(a) < 100001:
	a.append(int('1' * (k + 1) + '0' * k, 2))
	k += 1
n = int(input())
for i in a:
	if n % i == 0:
		ans.append(i)
print(max(ans))


n = int(input())
answer = 1

def check(num):
	degree = 0
	while num % 2 == 0:
		num //= 2
		degree += 1
	num += 1
	degree += 1
	while num % 2 == 0:
		num //= 2
		degree -= 1
	return num == 1 and degree == 0
for i in range(2, n + 1):
	if n % i == 0 and check(i):
		answer = i
print(answer)


n = int(input())
k = 1
res = k
while (2 ** k - 1) * 2 ** (k - 1) <= n:
	if n % ((2 ** k - 1) * 2 ** (k - 1)) == 0:
		res = k
	k += 1
print((2 ** res - 1) * 2 ** (res - 1))


n = int(input())
mas = []
k = -1
for i in range(1, 15):
	f = ((2 << i - 1) - 1) * ((2 << i - 1) // 2)
	if n % f == 0:
		k = f
print(k)


from collections import deque, Counter, OrderedDict
from heapq import nsmallest, nlargest
from math import ceil, floor, log, log2, sqrt

def binNumber(n, size=1):
	return bin(n)[2:].zfill(size)

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def iar():
	return list(map(int, input().split()))

def ini():
	return int(input())

def isp():
	return map(int, input().split())

def sti():
	return str(input())
n = ini()
for i in range(n, 0, -1):
	if n % i == 0:
		s = binNumber(i)
		if len(s) % 2 == 0:
			continue
		a = len(s) // 2 + 1
		if s[0:a] == '1' * a and s[a:] == '0' * (len(s) - a):
			print(i)
			quit()


n = int(input())
d = 0
for k in range(1, 21):
	if n % ((2 ** k - 1) * 2 ** (k - 1)) == 0:
		d = (2 ** k - 1) * 2 ** (k - 1)
print(d)


n = int(input())
maxc = int(0)
for i in range(1, n + 1):
	vv = (2 ** i - 1) * 2 ** (i - 1)
	if vv > n:
		break
	if n % vv == 0:
		if vv > maxc:
			maxc = vv
print(maxc)


n = int(input())
for k in range(13, 0, -1):
	if n % ((2 ** k - 1) * 2 ** (k - 1)) == 0:
		ans = (2 ** k - 1) * 2 ** (k - 1)
		break
print(ans)


bn = [130816, 32640, 8128, 2016, 496, 120, 28, 6, 1]
bn.reverse()
ans = 1
n = int(input())
for num in bn:
	if n % num == 0:
		ans = num
print(ans)


n = int(input())
max_ = 1
for i in range(1, n + 1):
	if n % i == 0:
		for j in range(1, 10):
			if i == (2 ** j - 1) * 2 ** (j - 1):
				max_ = max(max_, i)
print(max_)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
readint = lambda : int(sys.stdin.readline().rstrip('\r\n'))
readints = lambda : map(int, sys.stdin.readline().rstrip('\r\n').split())
readstr = lambda : sys.stdin.readline().rstrip('\r\n')
readstrs = lambda : map(str, sys.stdin.readline().rstrip('\r\n').split())
readarri = lambda : [int(_) for _ in sys.stdin.readline().rstrip('\r\n').split()]
readarrs = lambda : [str(_) for _ in sys.stdin.readline().rstrip('\r\n').split()]
beauty = []
for i in range(1, int(100000.0) + 1):
	bini = bin(i)[2:]
	if bini.count('1') == bini.count('0') + 1:
		check = bini.count('1')
		if bini[0:check] == '1' * check:
			beauty.append(i)

def solve():
	n = readint()
	for i in beauty[::-1]:
		if not n % i:
			print(i)
			return

def main():
	t = 1
	for _ in range(t):
		solve()
main()


arr = [33550336, 8386560, 2096128, 523776, 130816, 32640, 8128, 2016, 496, 120, 28, 6, 1]
n = int(input())
for i in arr:
	if n % i == 0:
		print(i)
		break


n = int(input())
a = []
for i in range(1, n + 1):
	if n % i == 0:
		a.append(i)
val = 1
for i in range(len(a) - 1, -1, -1):
	s = str(bin(a[i]))[2:]
	num = [0, 0]
	k = 1
	for j in s:
		if j == '0' and k == 1:
			k -= 1
		if j == '1' and k == 0:
			num = [0, 0]
			break
		num[k] += 1
	if num[1] == num[0] + 1:
		val = a[i]
		break
print(val)


n = int(input())
s = []
k = 1
while (2 ** k - 1) * 2 ** (k - 1) <= n:
	s.append((2 ** k - 1) * 2 ** (k - 1))
	k += 1
for c in reversed(s):
	if n % c == 0:
		print(c)
		break


import sys
f = sys.stdin
n = int(f.readline())
if n % 32640 == 0:
	print(32640)
elif n % 8128 == 0:
	print(8128)
elif n % 2016 == 0:
	print(2016)
elif n % 496 == 0:
	print(496)
elif n % 120 == 0:
	print(120)
elif n % 28 == 0:
	print(28)
elif n % 6 == 0:
	print(6)
else:
	print(1)


n = int(input())
d = [1]
z = '1'
while len(z) < 20:
	z = '1' + z + '0'
	d.append(int(z, 2))
x = 0
a = []
for i in range(len(d)):
	if n % d[i] == 0:
		a.append(d[i])
print(a[-1])


import os
import sys

def log(*args, **kwargs):
	if os.environ.get('CODEFR'):
		print(*args, **kwargs)
n = int(input())
k = (len(bin(n)) - 2) // 2
while k >= 0:
	d = int('1' * (k + 1) + '0' * k, 2)
	if n % d == 0:
		print(d)
		sys.exit(0)
	k -= 1


number = int(input())
beautiful_divs = [1, 6, 28, 120, 496, 2016, 8128, 32640, 130816]
for i in beautiful_divs:
	if number % i == 0:
		greater = i
print(greater)


import math

def solve(n):
	if n == 1:
		return 1
	nbits = math.ceil(math.log(n, 2))
	onbits = math.ceil(nbits / 2)
	offbits = onbits - 1
	while onbits > 0:
		v = (2 ** onbits - 1) * 2 ** offbits
		if n % v == 0:
			return v
		onbits -= 1
		offbits = onbits - 1
	return -1
print(solve(int(input())))


import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)
b = [(2 ** k - 1) * 2 ** (k - 1) for k in range(1, 9)]
n = ii()
ans = 1
for i in b:
	if n % i == 0:
		ans = max(ans, i)
print(ans)


def get_num(one):
	one *= 2
	rect = bin(one)
	sep = 2 ** (len(rect) - 2)
	return one + sep
(num, mx, res) = (int(input()), 1, 0)
while num // mx:
	if num % mx == 0:
		res = mx
	mx = get_num(mx)
print(res)


orig = int(input())
n = orig
while n > 0:
	if orig % n == 0:
		bn = bin(n)[2:]
		if bn.split('0')[0] == len(bn.split('0')[0]) * bn.split('0')[0][0]:
			if len(bn.split('0')[1:]) + 1 == len(bn.split('0')[0]) and ''.join(bn.split('0')[1:]) == '':
				print(n)
				break
	n -= 1


def check(n):
	m = n & -n
	if n == m * (2 * m - 1):
		return True
	return False
n = int(input())
if check(n):
	print(n)
	exit()
ans = 1
for i in range(2, n // 2 + 1):
	if n % i == 0 and check(i):
		ans = i
print(ans)


n = int(input())
k = 1
if n % 6 == 0:
	k = 6
if n % 28 == 0:
	k = 28
if n % 120 == 0:
	k = 120
if n % 496 == 0:
	k = 496
if n % 2016 == 0:
	k = 2016
if n % 8128 == 0:
	k = 8128
if n % 32640 == 0:
	k = 32640
print(k)


n = int(input())
l = [32640, 8128, 2016, 496, 120, 28, 6, 1]
for i in range(8):
	if not n % l[i]:
		print(l[i])
		break


mx = []
num = int(input())
ix = num
for i in range(ix, 0, -1):
	if num % i == 0:
		x = bin(i)
		strx = x[2:]
		(count1, count0) = (0, 0)
		for j in strx:
			if j == '0':
				count0 = count0 + 1
			else:
				count1 = count1 + 1
		if count1 - count0 == 1:
			for y in range(1, 18):
				if i == (2 ** y - 1) * 2 ** (y - 1):
					mx.append(i)
					break
print(mx[0])


n = int(input())
i = 1
temp = 0
while (2 ** i - 1) * 2 ** (i - 1) <= n:
	if n % ((2 ** i - 1) * 2 ** (i - 1)) == 0:
		temp = (2 ** i - 1) * 2 ** (i - 1)
	i += 1
print(temp)


def main():
	N = int(input())
	beautiful = []
	apnd = beautiful.append
	k = i = 1
	while i < 50000:
		i = (2 ** k - 1) * 2 ** (k - 1)
		apnd(i)
		k += 1
	beautiful.sort(reverse=True)
	for i in beautiful:
		if not N % i:
			print(i)
			break
main()


n = int(input())
anserws = [1, 6, 28, 120, 496, 2016, 8128, 32640]
for i in range(len(anserws) - 1, -1, -1):
	if n >= anserws[i]:
		if n % anserws[i] == 0:
			print(anserws[i])
			quit()


a = [1, 6, 28, 120, 496, 2016, 8128, 32640]
n = int(input())
t = 7
while n % a[t]:
	t -= 1
print(a[t])


import sys
import math
N = int(next(sys.stdin))
beautiful = [1]
k = 1
b = 1
while b < N:
	k += 1
	b = (math.pow(2, k) - 1) * math.pow(2, k - 1)
	beautiful.append(b)
for b in beautiful[::-1]:
	if N % b == 0:
		print('{:g}'.format(b))
		sys.exit()


a = [1, 6, 28, 120, 496, 2016, 8128, 32640]
b = int(input())
for i in range(0, 8):
	if b % a[i] == 0:
		c = a[i]
print(str(c))


candidate = []
for i in range(1, 10):
	candidate.append(int((2 ** i - 1) * 2 ** (i - 1)))
n = int(input())
for i in candidate[::-1]:
	if n % i == 0:
		print(i)
		break


n = int(input())
num = 1
k = 2
l = [1]
while num < n:
	num = (2 ** k - 1) * 2 ** (k - 1)
	if n % num == 0:
		l.append(num)
	k += 1
print(l[-1])


n = int(input())
b = set([2 ** k for k in range(20)])
for i in range(n, 0, -1):
	if n % i == 0:
		j = i
		k = 0
		while k < 20:
			if j / 2 ** k == 2 ** (k + 1) - 1:
				print(i)
				exit()
				break
			k += 1


z1 = []
for i in range(1, 11):
	z = '0' * (i - 1) + '1' * i
	s = 0
	for i in range(len(z)):
		if z[i] == '1':
			s += 1 << i
	z1 += [s]
a = int(input())
i = 0
w = 0
while i < 10:
	if a % z1[i] == 0:
		w = z1[i]
	i += 1
print(w)


n = int(input())
x = []
for i in range(1, n + 1):
	if n % i == 0:
		x.append(i)
for i in x[::-1]:
	if str(bin(i)[2:]).count('1') == str(bin(i)[2:]).count('0') + 1 and '1' * str(bin(i)[2:]).count('1') in str(bin(i)[2:]):
		print(i)
		break


a = '1'
b = []
while True:
	temp = int(a, 2)
	if temp > 100000:
		break
	b.append(temp)
	a = '1' + a + '0'
n = int(input())
temp = 0
for i in b:
	if i > n:
		break
	if n % i == 0:
		if i > temp:
			temp = i
print(temp)


import math
n = int(input())
k = int((math.log(n, 2) + 1) / 2) + 1
for j in range(k, 1, -1):
	gbv = int((math.pow(2, j) - 1) * math.pow(2, j - 1))
	if n % gbv == 0:
		print(gbv)
		exit()
print(1)


n = int(input())
ans = 1
for i in range(2, n + 1):
	for k in range(1, 18):
		x = (2 ** k - 1) * 2 ** (k - 1)
		if n % x == 0:
			ans = x
print(ans)


n = int(input())
ans = 0
for k in range(20):
	if n % ((2 ** (k + 1) - 1) * 2 ** k) is 0:
		ans = (2 ** (k + 1) - 1) * 2 ** k
print(ans)


q = int(input())
a = [1, 6, 28, 120, 496, 2016, 8128, 32640, 130816]
s = 0
for i in a:
	if q % i == 0:
		s = i
print(s)


n = int(input())
k = 1
while 1:
	x = (2 ** k - 1) * 2 ** (k - 1)
	if x > n:
		print(mx)
		quit()
	if n % x == 0:
		mx = x
	k += 1


n = int(input())
for i in range(n, 0, -1):
	if n % i == 0 and i in [1, 6, 28, 120, 496, 2016, 8128, 32640, 130816]:
		print(i)
		break


n = int(input())
a = []
i = 1
if n == 1:
	print(1)
else:
	while i <= n:
		a.append(i)
		i *= 2
	for i in range(len(a)):
		if n % ((a[len(a) - i - 1] - 1) * a[len(a) - i - 2]) == 0 and i <= len(a) - 2:
			k = (a[len(a) - i - 1] - 1) * a[len(a) - i - 2]
			break
	if k == 0:
		print(1)
	else:
		print(k)


def devisor(n):
	n = str(bin(n))[2:]
	if n.count('1') - n.count('0') == 1:
		for i in range(0, n.count('1')):
			if n[i] != '1':
				return False
		return True
	return False
n = int(input())
for i in range(n, 0, -1):
	if n % i == 0:
		if devisor(i):
			print(i)
			break


import math
N = int(input())
for n in range(N, 0, -1):
	if N % n == 0:
		nbits = int(math.log2(n)) + 1
		if nbits % 2 != 0:
			k = nbits // 2 + 1
			if (2 ** k - 1) * 2 ** (k - 1) == n:
				print(n)
				break


k = [1, 6, 28, 120, 496, 2016, 8128, 32640]
n = int(input())
for i in range(7, -1, -1):
	if n % k[i] == 0:
		print(k[i])
		break


l = ['110', '11100', '1111000', '111110000', '11111100000', '1111111000000', '111111110000000']
n = int(input())
b = True
for i in range(len(l)):
	m = int(l[i], 2)
	if n % m == 0:
		ans = m
		b = False
if b == True:
	print(1)
else:
	print(ans)


x = input()
y = 1
k = 1
bea = []
while y <= 100000:
	y = (2 ** k - 1) * 2 ** (k - 1)
	bea.append(y)
	k = k + 1
bea.pop(len(bea) - 1)
temp = 0
for j in range(len(bea)):
	if int(x) % bea[j] == 0:
		temp = bea[j]
print(temp)


def bin(n):
	s = ''
	while n != 0:
		s += str(n % 2)
		n //= 2
	s = s[::-1]
	return s

def beauteful(n):
	s = ''
	for i in range(len(str(bin(n))) // 2 + 1):
		s += '1'
	u = ''
	for i in range(len(str(bin(n))) // 2):
		u += '0'
	if str(bin(n)).count(s) == 1 and str(bin(n)).count(u) == 1 or n == 1:
		return True
	else:
		return False

def main(n):
	t = n
	while t != 0:
		if n % t == 0 and beauteful(t) == True:
			return t
		t -= 1
print(main(int(input())))


from math import gcd, ceil
from collections import defaultdict as dd

def lcm(a, b):
	return a * b // gcd(a, b)

def inin():
	return int(input())

def inar():
	return list(map(int, input().split()))

def ar(element, size):
	return [element for i in range(size)]

def digitsum(num):
	su = 0
	while num:
		su += num % 10
		num //= 10
	return su
ss = set()
for k in range(1, 11):
	num = '1' * k + '0' * (k - 1)
	ss.add(int(num, 2))
n = inin()
i = 1
ans = 1
while i * i <= n:
	if n % i == 0:
		div1 = i
		div2 = n // i
		if div1 in ss:
			ans = max(ans, div1)
		if div2 in ss:
			ans = max(ans, div2)
	i += 1
print(ans)


a = int(input())
w = 0
g = 1
while 2 ** (g - 1) * (2 ** g - 1) <= a:
	if a % (2 ** (g - 1) * (2 ** g - 1)) == 0:
		w = 2 ** (g - 1) * (2 ** g - 1)
	g += 1
print(w)


n = int(input())
max_div = 1
for k in range(1, 20):
	div = (2 ** k - 1) * 2 ** (k - 1)
	if n % div == 0:
		max_div = max(div, max_div)
print(max_div)


def ok(x: int):
	s = str(bin(x)[2:])
	for k in range(0, 30):
		if s == '1' * (k + 1) + '0' * k:
			return True
	return False
n = int(input())
i = 2
ans = 1
while i <= n:
	if n % i == 0:
		if ok(i):
			ans = max(ans, i)
	i += 1
print(ans)


l = [1, 6, 28, 120, 496, 2016, 8128, 32640, 130816]
n = int(input())
a = len(l) - 1
while n > l[a]:
	a -= 1
while n % l[a] != 0:
	a -= 1
print(l[a])


n = int(input())
(a, k) = (0, 0)
m = 1
while a <= n:
	k += 1
	a = (2 ** k - 1) * 2 ** (k - 1)
	if a <= n and n % a == 0:
		m = max(1, a)
print(m)


n = int(input())
l = []
for i in range(11):
	l.append((2 ** (i + 1) - 1) * 2 ** i)
i = 10
while i >= 0:
	if n % l[i] == 0:
		print(l[i])
		break
	i -= 1


n = int(input())
for g in [int('1' * k + '0' * (k - 1), 2) for k in range(9, 0, -1)]:
	if n % g == 0:
		print(g)
		break


nums = []
k = 0
while int((k + 1) * '1' + k * '0', 2) <= 10 ** 5:
	nums.append(int((k + 1) * '1' + k * '0', 2))
	k += 1
n = int(input())
for val in nums[::-1]:
	if n % val == 0:
		print(val)
		break


def tobin(x):
	t = ''
	while x > 1:
		t += str(x % 2)
		x = x // 2
	t += str(x)
	return t[::-1]
numero = int(input())
j = -1
divisor = 0
if numero % 2 == 0:
	iterar = numero / 2
else:
	iterar = (numero - 1) / 2
for i in range(1, int(iterar) + 1):
	if numero % i == 0:
		aux = numero / i
		if aux != divisor:
			divisor = aux
		if i == iterar:
			h = tobin(int(divisor))
			if len(h) % 2 != 0:
				lent = int((len(h) - 1) / 2)
				g = h[0:lent + 1]
				t = int(h[lent + 1:len(h)])
				m = 1
				for x in g:
					if x == '0':
						m = -1
						break
				if t == 0 and m == 1:
					j = 1
					print(int(divisor))
					break
		else:
			h = tobin(int(divisor))
			if len(h) % 2 != 0:
				lent = int((len(h) - 1) / 2)
				g = h[0:lent + 1]
				t = int(h[lent + 1:len(h)])
				m = 1
				for x in g:
					if x == '0':
						m = -1
						break
				if t == 0 and m == 1:
					j = 1
					print(int(divisor))
					break
if j == -1:
	print(1)


n = int(input())
for i in range(11):
	x = 2 ** i * (2 ** (i + 1) - 1)
	if n % x == 0:
		ans = x
print(ans)


def get_b():
	k = 1
	b = []
	while 1:
		num = (2 ** k - 1) * 2 ** (k - 1)
		if num <= 100000:
			b.append(num)
			k += 1
		else:
			return b

def cd(num, b):
	div = 1
	for i in range(1, len(b)):
		if num % b[i] == 0:
			div = b[i]
	return div

def main():
	b = get_b()
	n = int(input())
	div = cd(n, b)
	print(div)
main()


index = 1
n = int(input())
div = 1
for i in range(8):
	g = '1' * index + '0' * (index - 1)
	w = int(g, 2)
	if n % w == 0:
		div = w
	index += 1
print(div)


def pow2(k):
	p = 1
	while k > 0:
		p *= 2
		k -= 1
	return p

def beau(k):
	return (pow2(k) - 1) * pow2(k - 1)

def maxBeauDivisor(n):
	b = 1
	for k in range(1, 32):
		temp = beau(k)
		if temp > n:
			break
		if n % temp == 0:
			b = temp
	return b

def ni():
	s = input()
	while len(s) == 0:
		s = input()
	try:
		return int(s)
	except:
		return 0
n = ni()
print(maxBeauDivisor(n))


n = int(input())
c = 1
for k in range(1, 20):
	x = (2 ** k - 1) * 2 ** (k - 1)
	if n % x == 0:
		c = x
print(c)


def isBeau(x):
	x = bin(x)[2:]
	if len(x) % 2 == 0:
		return False
	else:
		if x[:len(x) // 2 + 1] != '1' * (len(x) // 2 + 1):
			return False
		if x[len(x) // 2 + 1:] != '0' * (len(x) // 2):
			return False
	return True
cur = 1
n = int(input())
for i in range(1, round(n ** (1 / 2)) + 1):
	if n % i == 0 and isBeau(i):
		cur = max(cur, i)
	if n % i == 0 and isBeau(n // i):
		cur = max(cur, n // i)
print(cur)


def main():
	n = int(input())
	k = 1
	num = 1
	ans = 1
	while num <= n:
		num = (2 ** k - 1) * 2 ** (k - 1)
		if n % num == 0:
			ans = num
		k += 1
	print(ans)
main()


n = int(input())
for elem in [523776, 130816, 32640, 8128, 2016, 496, 120, 28, 6, 1]:
	if n % elem == 0:
		print(elem)
		break


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
N = int(input())

def check(v):
	b = bin(v)[2:]
	if len(b) % 2 == 0:
		return False
	h = len(b) // 2
	if b == '1' * (h + 1) + '0' * h:
		return True
	return False
if check(N):
	print(N)
	exit(0)
for v in range(N // 2, 0, -1):
	if N % v == 0:
		if check(v):
			print(v)
			exit(0)
print(1)


from math import *
a = int(input())
v_2 = 0
while a % 2 == 0:
	a /= 2
	v_2 += 1
k = 1
if v_2 > 0:
	for i in range(v_2, 0, -1):
		if a % (2 ** (i + 1) - 1) == 0:
			k = i + 1
			break
print((2 ** k - 1) * 2 ** (k - 1))


n = int(input())
for i in range(1001, 0, -1):
	if n % ((2 ** i - 1) * 2 ** (i - 1)) == 0:
		print((2 ** i - 1) * 2 ** (i - 1))
		break


div = [32640, 8128, 2016, 496, 120, 28, 6, 1]
n = int(input())
for i in div:
	if n % i == 0:
		print(i)
		break


n = int(input())

def isb(x):
	b = bin(x)[2:]
	k = len(b)
	if k % 2 == 0:
		return 0
	k = k // 2
	for i in b[:k + 1]:
		if i != '1':
			return 0
	for i in b[k + 1:]:
		if i != '0':
			return 0
	return 1
if isb(n):
	print(n)
else:
	for i in range(int(n // 2), 0, -1):
		if n % i == 0:
			if isb(i):
				print(i)
				break


cur = '1'
beautiful = [int(cur, 2)]
while int(cur, 2) < 100000.0:
	cur = '1' + cur + '0'
	beautiful.append(int(cur, 2))
n = int(input())
for x in beautiful[::-1]:
	if n % x == 0:
		print(x)
		break


def calc(k):
	return (2 ** k - 1) * 2 ** (k - 1)

def main():
	n = int(input())
	idx = 1
	lst = list()
	while calc(idx) <= n:
		lst.append(calc(idx))
		idx += 1
	for item in reversed(lst):
		if n % item == 0:
			print(item)
			exit(0)
main()


def f(x):
	i = x & -x
	if x % i == 0 and x // i == 2 * i - 1:
		return True
	return False
n = int(input())
res = 1
for i in range(2, n + 1):
	if f(i) and n % i == 0:
		res = i
print(res)


n = int(input())
ans = 1
for i in range(1, n + 1):
	if n % i != 0:
		continue
	b = bin(i)[2:]
	j = 0
	while j < len(b) and b[j] == '1':
		j += 1
	ex = 1
	k = j
	while k < len(b) and b[k] == '0':
		k += 1
	k -= 1
	if k == len(b) - 1:
		if j == k - j + 2:
			ans = i
print(ans)


def main():
	n = lie()
	ans = 0
	for i in range(1, int(sqrt(n)) + 1):
		if n % i == 0:
			if fun(binary(i)):
				ans = max(ans, i)
			if fun(binary(n // i)):
				ans = max(ans, n // i)
	print(ans)

def binary(temp):
	s = ''
	while temp:
		s += str(temp % 2)
		temp //= 2
	return s[::-1]

def fun(s):
	if len(s) % 2 == 1:
		f = True
		k = (len(s) - 1) // 2
		for i in range(k + 1):
			if s[i] != '1':
				f = False
				break
		for i in range(k + 1, len(s)):
			if s[i] != '0':
				f = False
				break
		return f
	else:
		return False
from sys import *
import inspect
import re
from math import *
import threading
from collections import *
from pprint import pprint as pp
mod = 998244353
MAX = 10 ** 5

def lie():
	return int(input())

def liee():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def deb(p):
	for line in inspect.getframeinfo(inspect.currentframe().f_back)[3]:
		m = re.search('\\bdeb\\s*\\(\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*\\)', line)
		print('%s %d' % (m.group(1), p))

def vector(size, val=0):
	vec = [val for i in range(size)]
	return vec

def matrix(rowNum, colNum, val=0):
	mat = []
	for i in range(rowNum):
		collumn = [val for j in range(colNum)]
		mat.append(collumn)
	return mat

def dmain():
	setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
dmain()


beautiful = []
for i in range(1, 10):
	beautiful.append((2 ** i - 1) * 2 ** (i - 1))
n = int(input())
largest = 1
for i in beautiful:
	if n % i == 0:
		largest = i
print(largest)


n = int(input())
k = 1
lst = []
while True:
	a = 2 ** (k - 1)
	num = (2 * a - 1) * a
	if n % num == 0:
		lst.append(num)
	if num > n // 2:
		break
	k += 1
print(max(lst))


def main():
	from sys import stdin, stdout
	dp = [1]
	i = 0
	while True:
		x = dp[i]
		dis = (i + 1) * 2 - 1
		x += 1 << dis
		x <<= 1
		dp.append(x)
		i += 1
		if x > int(100000.0):
			break
	N = int(stdin.readline())
	i -= 1
	while i >= 0:
		if N % dp[i] == 0:
			stdout.write(str(dp[i]))
			break
		i -= 1
main()


n = int(input())
l = []
for i in range(n):
	if 2 ** i <= n:
		l.append(2 ** i)
	else:
		break
l.sort(reverse=True)
c = 0
for j in l:
	if n % j == 0 and n % (j * 2 - 1) == 0:
		print(j * (j * 2 - 1))
		break


n = int(input())

def check(p, r):
	return (2 ** p - 1) * 2 ** (p - 1) > r

def binSearch(a, b, r):
	(left, right) = (a - 1, b + 1)
	while right - left > 1:
		mid = (right + left) // 2
		if check(mid, r):
			right = mid
		else:
			left = mid
	return left

def check_eq(p, r):
	return (2 ** p - 1) * 2 ** (p - 1) == r
for i in reversed(range(1, n + 1)):
	if n % i == 0:
		if check_eq(binSearch(0, n, i), i):
			print(i)
			exit()


def p(a, b):
	if b == 0:
		return 1
	if b % 2 == 0:
		return p(p(a, b // 2), 2)
	else:
		return p(a, b - 1) * a
n = int(input())
ans = 1
ans1 = 1
i = 1
while n >= ans:
	if n % ans == 0:
		ans1 = ans
	ans = (pow(2, i) - 1) * pow(2, i - 1)
	i += 1
print(ans1)


n = int(input())
d = []
i = 1
while i * i <= n:
	if n % i == 0:
		d.append(i)
		if n // i != i:
			d.append(n // i)
	i += 1
d.sort(reverse=True)

def cnt(n):
	c = 0
	while n != 0:
		c += 1
		n = n // 2
	return c
for i in range(len(d)):
	if cnt(d[i]) % 2:
		k = (cnt(d[i]) + 1) // 2
		if d[i] % 2 ** (k - 1) == 0 and d[i] // 2 ** (k - 1) == 2 ** k - 1:
			print(d[i])
			break


n = int(input())
for k in reversed(range(9)):
	d = (2 ** k - 1) * 2 ** (k - 1)
	if n % d == 0:
		print(d)
		break


a = [0, 1, 6, 28, 120, 496, 2016, 8128, 32640, 130816, 523776, 2096128, 8386560, 33550336, 134209536, 536854528]
s = int(input())
for i in range(14, 0, -1):
	if s % a[i] == 0:
		print(a[i])
		break


n = int(input())
x1 = n
while x1 > 0:
	if n % x1 == 0:
		count = 0
		x = x1
		while x % 2 == 0:
			x = x / 2
			count += 1
		g = 1
		count1 = 0
		for i in range(count):
			g = g * 2 + 1
			count1 += 1
		if x == g:
			print(int(x * 2 ** count))
			x1 = 0
	x1 -= 1


powers = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 2096, 8192, 16384, 32768, 65536]
l = len(powers)
n = int(input())
ans = 1
for i in range(l):
	if n % powers[i] == 0:
		other = 2 ** (i + 1) - 1
		if n % other == 0:
			ans = powers[i] * other
	else:
		break
print(ans)


li = []
for i in range(1, 9):
	a = (2 ** i - 1) * 2 ** (i - 1)
	li.append(a)
li = li[::-1]
n = int(input())
for i in li:
	if n % i == 0:
		print(i)
		break


import sys
import math
import bisect
import itertools
import random
import re

def query_decimal_from_binary(A):
	ans = 0
	for a in A:
		ans = ans * 2 + a
	return ans

def main():
	n = int(input())
	B = []
	for i in range(10):
		A = []
		for j in range(i + 1):
			A.append(1)
		for j in range(i):
			A.append(0)
		B.append(query_decimal_from_binary(A))
	ans = []
	for b in B:
		if n % b == 0:
			ans.append(b)
	print(max(ans))
main()


ans = 1
n = int(input())
for k in range(1, 10):
	p = (2 ** k - 1) * 2 ** (k - 1)
	if n % p == 0:
		ans = max(ans, p)
print(ans)


print((lambda divisors, n: max([x for x in divisors if n % x == 0]))([2 ** (i - 1) * (2 ** i - 1) for i in range(1, 40)], int(input())))


def countMaxSetBits(left, right):
	while left | left + 1 <= right:
		left |= left + 1
	return left
n = int(input())
ans = 1
for k in range(1, 10):
	var = (2 ** k - 1) * 2 ** (k - 1)
	if var > n:
		print(ans)
		break
	if n % var == 0:
		ans = var


n = int(input())
div = [1]
k = 2
while div[-1] < n:
	div.append((2 ** k - 1) * 2 ** (k - 1))
	k += 1
for x in reversed(div):
	if n % x == 0:
		print(x)
		break


from sys import stdin, stdout
n = int(stdin.readline())
dividers = []
sze = 20
for i in range(1, sze):
	v = ((1 << i) - 1) * (1 << i - 1)
	dividers.append(v)
for v in dividers[::-1]:
	if not n % v:
		stdout.write(str(v))
		break


bd = [1, 6, 28, 120, 496, 2016, 8128, 32640]
test = int(input())
for x in range(len(bd) - 1, -1, -1):
	if test % bd[x] == 0:
		print(bd[x])
		break


l = []
for i in range(1, 100):
	x = (2 ** i - 1) * 2 ** (i - 1)
	if x > 100000:
		break
	l.append(x)
l = l[::-1]
k = int(input())
ans = 0
for i in l:
	if k % i == 0:
		print(i)
		break


n = int(input())
dmax = 1
k = 2
d = (1 << k) - 1 << k - 1
while d <= n:
	if n % d == 0:
		dmax = d
	k += 1
	d = (1 << k) - 1 << k - 1
print(dmax)


def f(k):
	return (2 ** k - 1) * 2 ** (k - 1)
(k, n) = (1, int(input()))
(i, maxi) = (f(k), -1)
while i <= n:
	if n % i == 0:
		maxi = i
	i = f(k + 1)
	k += 1
print(maxi)


def solve(m):
	k = 1
	while m % 2 == 0:
		m //= 2
		k += 1
	while m % ((1 << k) - 1) != 0:
		k -= 1
	return ((1 << k) - 1) * (1 << k - 1)
n = int(input())
print(solve(n))


def fun(n):
	len = 0
	while n > 0:
		n = n // 2
		len = len + 1
	return len
n = int(input())
len = fun(n)
if len % 2 == 0:
	x = (len + 1) // 2 + 1
	y = (len + 1) // 2
else:
	x = len // 2 + 1
	y = len // 2
val = 1
while val > 0:
	val = pow(2, x + y) - pow(2, y)
	if n % val == 0:
		print(val)
		break
	else:
		x = x - 1
		y = y - 1


n = int(input())
pow2 = [2 ** i for i in range(31)]
for i in range(30, 0, -1):
	if n % ((pow2[i] - 1) * pow2[i - 1]) == 0:
		print((pow2[i] - 1) * pow2[i - 1])
		exit()


z1 = [1, 6, 28, 120, 496, 2016, 8128, 32640, 130816]
a = int(input())
w = 0
i = 0
while i < 9:
	if a % z1[i] == 0:
		w = z1[i]
	i += 1
print(w)


import sys
import math

def calc_beautiful(k):
	return (math.pow(2, k) - 1) * math.pow(2, k - 1)
inp = int(sys.stdin.readline().rstrip())
max = 1
i = 2
n = calc_beautiful(i)
while n <= inp:
	if inp % n == 0:
		max = n
	i = i + 1
	n = calc_beautiful(i)
print(int(max))


n = int(input())
ans = 1
start = '110'
while True:
	a = int(start, 2)
	if a > n:
		break
	if n % a == 0:
		ans = a
	start = '1' + start + '0'
print(ans)


n = int(input())

def isOk(x):
	k = 1
	s = 0
	while s <= x:
		s = (1 << k) - 1 << k - 1
		if s == x:
			return True
		k += 1
	return False
res = 0
i = 1
while i * i <= n:
	if n % i == 0:
		if isOk(n // i):
			res = n // i
			break
		elif isOk(i):
			res = i
	i += 1
print(res)


def main():
	n = int(input())
	i = 1
	temp = 2 ** i
	fact = (temp - 1) * (temp // 2)
	ans = 1
	while fact <= n:
		if n % fact == 0:
			ans = fact
		i += 1
		temp = 2 ** i
		fact = (temp - 1) * (temp // 2)
	print(ans)
main()


def solve():
	n = int(input())
	ans = 1
	for i in range(1, 20):
		b = (2 ** i - 1) * 2 ** (i - 1)
		if n % b == 0:
			ans = max(ans, b)
	print(ans)
solve()


def divi(n):
	a = []
	for i in range(1, n + 1):
		if n % i == 0:
			a.append(i)
	return a
n = int(input())
x = divi(n)
for i in x[::-1]:
	k = bin(i)
	a = k[2:].count('1')
	b = k[2:].count('0')
	p = '1' * a
	q = '0' * b
	if a - b == 1 and k[2:].find(p) != -1 and (k[2:].find(q) != -1):
		print(i)
		break


from math import *
n = int(input())
x = ceil(log(n / 2, 2))
if n == 1 or n == 2:
	print(1)
else:
	while True:
		if n % ((pow(2, x) - 1) * pow(2, x - 1)) == 0:
			break
		else:
			x = x - 1
	print(int((pow(2, x) - 1) * pow(2, x - 1)))


def check(w):
	w = bin(w)
	w = w.split('b')[1]
	w = str(w)
	lens = len(w)
	s = 0
	n = 0
	for x in range(0, lens):
		if w[x] == '1':
			s += 1
		else:
			n += 1
		if x != lens - 1 and w[x] == '0' and (w[x + 1] == '1'):
			return False
	if s - n == 1:
		return True
	else:
		return False
while True:
	try:
		n = int(input())
		flag = 0
		for x in range(n, 0, -1):
			if n % x == 0:
				if check(x):
					flag = x
					break
		print(flag)
	except EOFError:
		break


n = int(input())
l = [1]
c = 1
k = 1
while c <= n:
	if c >= n:
		break
	c = c * 4
	k = k * 2
	c = c + k
	l.append(c)
o = 0
for i in range(len(l)):
	if n % l[i] == 0:
		o = l[i]
print(o)


n = int(input())
for i in range(20, 0, -1):
	a = 2 ** (i - 1) * (2 ** i - 1)
	if n % a == 0:
		print(a)
		break


a = [1, 6, 28, 120, 496, 2016, 8128, 32640]
n = int(input())
i = 7
while n % a[i] != 0:
	i -= 1
print(a[i])


n = int(input())

def answer(n):
	b = []
	for i in range(1, 10):
		b.append((2 ** i - 1) * 2 ** (i - 1))
	for i in range(len(b) - 1, -1, -1):
		if b[i] <= n and n % b[i] == 0:
			return b[i]
print(answer(n))


n = int(input())
x = 1
for k in range(1, 15):
	if n % ((pow(2, k) - 1) * pow(2, k - 1)) == 0:
		x = (pow(2, k) - 1) * pow(2, k - 1)
print(x)


numbers = [1, 6, 28, 120, 496, 2016, 8128, 32640, 130816]
n = int(input())
a = 1
for i in numbers:
	if n % i == 0:
		a = i
print(a)


n = int(input())
i = 1
greatest = 1

def check(n):
	global greatest
	b = bin(n).replace('0b', '')
	a = 0
	c = 0
	for i in range(len(b)):
		if b[i] == '1' and i <= len(b) // 2:
			a += 1
		if b[i] == '0' and i > len(b) // 2:
			c += 1
	if a + c == len(b) and a == c + 1:
		greatest = n

def nextt(i):
	b = bin(i).replace('0b', '')
	b = '1' + b + '0'
	return int(b, 2)
while i <= n / 2:
	if n % i == 0:
		greatest = i
		i = nextt(i)
	else:
		i = nextt(i)
check(n)
print(greatest)


def beau(k):
	return (2 ** k - 1) * 2 ** (k - 1)

class CodeforcesTask893BSolution:

	def __init__(self):
		self.result = ''
		self.n = 0

	def read_input(self):
		self.n = int(input())

	def process_task(self):
		k = 1
		mx = 1
		while beau(k) <= self.n:
			if not self.n % beau(k):
				mx = beau(k)
			k += 1
		self.result = str(int(mx))

	def get_result(self):
		return self.result
Solution = CodeforcesTask893BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


def f(k):
	return (2 ** k - 1) * 2 ** (k - 1)
n = int(input())
m = 1
i = 2
while True:
	new = f(i)
	if new > n:
		break
	if n % new == 0 and new > m:
		m = new
	i += 1
print(m)


bn = [1, 6, 28, 120, 496, 2016, 8128, 32640]
n = int(input())
ans = 1
t = 1
while t * t <= n:
	if n % t == 0:
		a = n // t
		if a in bn:
			if a > ans:
				ans = a
		elif t in bn:
			if t > ans:
				ans = t
	t += 1
print(ans)


A = []
A.append(1)
for i in range(1, 10):
	str1 = ''
	for j in range(0, i + 1):
		str1 += '1'
	for j in range(0, i):
		str1 += '0'
	A.append(int(str1, 2))
n = int(input())
max1 = 0
for i in A:
	if n % i == 0:
		max1 = max(max1, i)
print(max1)


a = (32640, 8128, 2016, 496, 120, 28, 6, 1)
b = int(input())
print(a[[b % i for i in a].index(0)])


(list, var, i) = ([], 1, 1)
while var < int(100000.0):
	var = (2 ** i - 1) * 2 ** (i - 1)
	list.append(var)
	i += 1
n = int(input())
for i in list:
	if n % i == 0:
		var = i
print(var)


n = int(input())
x = [1, 6, 28, 120, 496, 2016, 8128, 32640]
i = 7
while i >= 0:
	if n % x[i] == 0:
		print(x[i])
		break
	i -= 1


n = int(input())
l = [0 for j in range(n + 1)]
i = 1
while (2 ** i - 1) * 2 ** (i - 1) <= n:
	if n % ((2 ** i - 1) * 2 ** (i - 1)) == 0:
		l[i] = (2 ** i - 1) * 2 ** (i - 1)
	i += 1
if n <= 3:
	print('1')
else:
	print(max(l))


def main():
	n = int(input())
	beautiful = '110'
	gbd = 1
	temp = int(beautiful, 2)
	while temp <= n:
		if n % temp == 0:
			gbd = temp
		beautiful = '1' + beautiful + '0'
		temp = int(beautiful, 2)
	print(gbd)
main()


n = int(input())
s = [(2 ** k - 1) * 2 ** (k - 1) for k in range(1, 9)]
s.sort(reverse=True)
for i in range(8):
	if n % s[i] == 0:
		print(s[i])
		break


n = int(input())
c = 1
good = 1
while c <= n:
	if n % c == 0:
		good = c
	c = int('1' + bin(c)[2:] + '0', 2)
print(good)


a = 0
a = int(input())
arr = []
for k in range(0, 100):
	arr.append(int((2 ** k - 1) * 2 ** (k - 1)))
for k in range(99, -1, -1):
	if a % arr[k] == 0:
		print(arr[k])
		break


n = int(input())
ans = 0
for i in range(1, 20):
	a = int((2 ** i - 1) * 2 ** (i - 1))
	if n % a == 0:
		ans = max(ans, a)
print(ans)


n = int(input())

def is_beautiful(n):
	k = 1
	while (2 ** k - 1) * 2 ** (k - 1) < n:
		k += 1
	if (2 ** k - 1) * 2 ** (k - 1) == n:
		return True
	else:
		return False
for i in range(n, 0, -1):
	if is_beautiful(i) == True and n % i == 0:
		print(i)
		break
	else:
		pass


def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
b = [(1 << k + 1) - 1 << k for k in range(10)]
b.reverse()
n = ii()
for x in b:
	if n % x == 0:
		print(x)
		break


n = int(input())
x = '{0:b}'.format(n)
lx = len(x)
if lx % 2 == 0:
	lx -= 1
new = ''
while lx >= 1:
	new = '1' * (lx // 2 + 1) + '0' * (lx // 2)
	d = int(new, 2)
	if n % d == 0:
		exit(print(d))
	lx -= 2


import math

def main_function():
	n = int(input())
	t = n
	l = n
	k = 0
	while t % 2 == 0:
		k += 1
		t = t // 2
	while l % (2 ** k * (2 ** (k + 1) - 1)) != 0:
		k -= 1
	print(2 ** k * (2 ** (k + 1) - 1))
main_function()


n = int(input())
l = []
k = 1
num = 0
while num <= 100000:
	num = (2 ** k - 1) * 2 ** (k - 1)
	if num <= 100000:
		l.append(num)
	k += 1
ans = 1
for each in l:
	if n % each == 0:
		ans = each
print(ans)


num = int(input())
divisors = [div for div in range(1, num + 1) if num % div == 0]
beautifuldiv = [(2 ** k - 1) * 2 ** (k - 1) for k in range(1, 10)]
for div in divisors[::-1]:
	if div in beautifuldiv:
		print(div)
		break


l = []
for i in range(1, 9):
	l.append((2 ** i - 1) * 2 ** (i - 1))
n = int(input())
for i in range(7, -1, -1):
	if n % l[i] == 0:
		print(l[i])
		break


a = int(input())
if a % 32640 is 0:
	print(32640)
elif a % 8128 is 0:
	print(8128)
elif a % 2016 is 0:
	print(2016)
elif a % 496 is 0:
	print(496)
elif a % 120 is 0:
	print(120)
elif a % 28 is 0:
	print(28)
elif a % 6 is 0:
	print(6)
else:
	print(1)


n = int(input())
l = []
k = 1
while int('1' * k + '0' * (k - 1), 2) <= n:
	l.append(int('1' * k + '0' * (k - 1), 2))
	k += 1
for i in range(len(l)):
	if n % l[-(i + 1)] == 0:
		print(l[-(i + 1)])
		exit()


n = int(input())
k = 1
t = 1
maxt = 1
while t <= n:
	k += 1
	t = (2 ** k - 1) * 2 ** (k - 1)
	if n % t == 0:
		maxt = t
print(maxt)


def beautiful_number(former_beautifulnumber, k):
	return 4 * former_beautifulnumber + 2 ** k
num = int(input())
beautiful_no = 1
k = 1
less_beautiful = []
while beautiful_no <= num:
	former_beautiful = beautiful_no
	beautiful_no = beautiful_number(beautiful_no, k)
	k += 1
	less_beautiful.append(former_beautiful)
for i in range(len(less_beautiful) - 1, -1, -1):
	if num % less_beautiful[i] == 0:
		print(less_beautiful[i])
		break


from math import sqrt
import sys
input = sys.stdin.readline
n = int(input())
div = []
for i in range(1, int(sqrt(n)) + 1):
	if n % i == 0:
		div.append(i)
		div.append(n // i)
div.sort(reverse=True)
for x in div:
	k = 0
	while (2 ** k - 1) * 2 ** (k - 1) <= x:
		if (2 ** k - 1) * 2 ** (k - 1) == x:
			print(x)
			exit()
		k += 1


n = int(input())
i = 1
max = 0
while (2 ** i - 1) * 2 ** (i - 1) <= n:
	if n % ((2 ** i - 1) * 2 ** (i - 1)) == 0:
		max = i
	i += 1
print((2 ** max - 1) * 2 ** (max - 1))


lista1 = []
a = int(input())
for i in range(1, int(a ** 0.5 + 1)):
	if a % i == 0:
		lista1.append(i)
		lista1.append(int(a / i))
lista1.sort(reverse=True)
k = 1
w = 0
lista = []
while w <= 10 ** 6:
	w = int((2 ** k - 1) * 2 ** (k - 1))
	lista.append(w)
	k += 1
for i in lista1:
	if i in lista:
		print(i)
		break


n = int(input())
for i in range(1, n + 1):
	d = (2 ** i - 1) * 2 ** (i - 1)
	if d > n:
		break
	elif n % d == 0:
		a = d
print(a)


n = int(input())
d = [[i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0]
d = sorted(set(sum(d, [])))
for x in d[::-1]:
	b = bin(x)[2:]
	l = len(b) // 2 + 1
	if len(b) % 2 == 1 and b[:l] == '1' * l and (b[l:] == '0' * (l - 1)):
		print(x)
		break


ans = []
a = 1
while True:
	ans.append((2 ** a - 1) * 2 ** (a - 1))
	a += 1
	if ans[-1] > 100000:
		break
m = int(input())
ans = ans[::-1]
for i in ans:
	if m % i == 0:
		print(i)
		break


def uberi(s):
	lol = ''
	for i in range(len(s) - 2):
		if i <= (len(s) - 2) // 2:
			lol += '1'
		else:
			lol += '0'
	return lol
a = int(input())
ans = ''
s = ''
check = 0
bina = str(bin(a))
for i in range(len(bina) - 2):
	s += bina[2 + i]
if len(s) % 2 == 0:
	kek = len(s) // 2
	tr = len(s) - 1
else:
	kek = len(s) // 2 + 1
	tr = len(s)
for i in range(tr):
	if i <= tr // 2:
		ans += '1'
	else:
		ans += '0'
for i in range(kek):
	if a % int(ans, 2) == 0 and check == 0:
		check = 1
		print(int(ans, 2))
	elif check == 0:
		ans = uberi(ans)


import sys
n = int(input())
ans = 1
for i in range(1, 30):
	x = int('1' * i + '0' * (i - 1), 2)
	if n % x == 0:
		ans = x
print(ans)


def b(n):
	s = '{0:b}'.format(n)
	l = len(s)
	return l % 2 == 1 and s[:l // 2 + 1] == '1' * (l // 2 + 1) and (s[l // 2 + 1:] == '0' * (l // 2))
l = int(input())
print(max((i for i in range(1, l + 1) if l % i == 0 and b(i))))


l = [1, 6, 28, 120, 496, 2016, 8128, 32640]
n = int(input())
for i in range(7, -1, -1):
	if n % l[i] == 0:
		print(l[i])
		exit()


n = int(input())
ma = 0
k = 1
a = 1
while a <= n:
	a = (2 ** k - 1) * 2 ** (k - 1)
	if n % a == 0:
		ma = a
	k += 1
print(ma)


import math

def divisors(num):
	divisors = []
	for i in range(1, math.ceil(math.sqrt(num)) + 1):
		if num % i == 0:
			divisors.append(i)
			divisors.append(int(num / i))
	divisors.sort()
	return divisors
divisors = divisors(int(input()))
beautiful = []
k = 0
while (2 ** k - 1) * 2 ** (k - 1) <= 100000:
	res = ''
	for i in range(k + 1):
		res = res + '1'
	for i in range(k):
		res = res + '0'
	beautiful.append(int((2 ** k - 1) * 2 ** (k - 1)))
	k = k + 1
maximum = 1
for i in divisors:
	for k in beautiful:
		if k == i:
			maximum = i
print(maximum)


n = int(input())
k = 1
while 2 ** (k - 1) * (2 ** k - 1) <= n:
	if n % (2 ** (k - 1) * (2 ** k - 1)) == 0:
		answer = 2 ** (k - 1) * (2 ** k - 1)
	k += 1
print(answer)


limit = 100000
i = 1
L = []
while True:
	tmp = int('1' * i + '0' * (i - 1), 2)
	if tmp > limit:
		break
	L.append(tmp)
	i += 1
n = int(input())
for i in range(len(L) - 1, -1, -1):
	if n % L[i] == 0:
		print(L[i])
		break


def isBeautiful(n: int) -> bool:
	num = bin(n)[2:]
	if len(num) % 2 == 0:
		return False
	k = len(num) // 2
	return num[:k + 1] == '1' * (k + 1) and num[k + 1:] == '0' * k
n = int(input())
if isBeautiful(n):
	print(n)
else:
	for i in range(n // 2, 0, -1):
		if n % i == 0 and isBeautiful(i):
			print(i)
			break


n = int(input())

def check(x):
	b = bin(x)[2:]
	k = len(b)
	if k & 1 and b[:k // 2 + 1] == '1' * (k // 2 + 1) and (b[k // 2 + 1:] == '0' * (k // 2)):
		return 1
	return 0
for i in range(n, -0, -1):
	if n % i == 0:
		if check(i):
			print(i)
			exit()


from collections import deque, defaultdict, Counter
from itertools import product, groupby, permutations, combinations
from math import gcd, floor, inf
from bisect import bisect_right, bisect_left
n = int(input())
beauty = []
for i in range(1, 1000):
	b = int('1' * i + '0' * (i - 1), 2)
	beauty.append(b)
	if b > 10 ** 5:
		break
beauty = beauty[::-1]
for div in beauty:
	if n % div == 0:
		print(div)
		break


n = int(input())
mx = 1

def check(v):
	s = bin(v)[2:]
	k = s.count('1')
	if '1' * k + '0' * (k - 1) == s:
		return 1
	return 0
for i in range(1, n + 1):
	if n % i:
		continue
	if check(i) and i > mx:
		mx = i
print(mx)


(z, zz, dgraphs) = (input, lambda : list(map(int, z().split())), {})
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())
for i in range(num, 0, -1):
	x = bin(i)[2:]
	if len(x) % 2 == 0 or num % i != 0:
		continue
	one = x.count('1')
	zerr = x.count('0')
	if one - zerr == 1 and x.count('1' * one) == 1 and (x.count('0' * zerr) == 1):
		print(i)
		exit()
print(1)


import math

def isbeautiful(N):
	k = math.log(((1 + 8 * N) ** 0.5 + 1) / 2, 2)
	if k == int(k):
		return True

def hello():
	n = int(input())
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			if isbeautiful(int(n / i)):
				print(int(n / i))
				return
	for i in range(int(n ** 0.5), 0, -1):
		if n % i == 0:
			if isbeautiful(i):
				print(i)
				return
hello()


from sys import stdin, stdout
from collections import Counter

def ai():
	return list(map(int, stdin.readline().split()))

def ei():
	return map(int, stdin.readline().split())

def ip():
	return int(stdin.readline().strip())

def op(ans):
	return stdout.write(str(ans) + '\n')
a = [1, 6, 28, 120, 496, 2016, 8128, 32640]
n = ip()
i = 7
while n % a[i]:
	i -= 1
print(a[i])


n = int(input())
i = 1
while 1:
	t = (2 ** i - 1) * 2 ** (i - 1)
	if t <= n:
		if n % t == 0:
			rs = t
	else:
		break
	i += 1
print(rs)


n = int(input())
Line = []
for k in range(1, 10):
	Line.append((2 ** k - 1) * 2 ** (k - 1))
for m in Line:
	if n % m == 0:
		p = m
print(p)


n = int(input())
l = [1, 6, 28, 120, 496, 2016, 8128, 32640]
l.sort(reverse=True)
for i in l:
	if n % i == 0:
		print(i)
		break


import math
a = []
for k in range(1, 12):
	a.append((int(math.pow(2, k)) - 1) * int(math.pow(2, k - 1)))
a = a[::-1]
n = int(input())
for i in a:
	if n % i == 0:
		print(i)
		break


n = int(input())
cur = 0
maxcur = 0
k = 1
while cur < n:
	cur = (2 ** k - 1) * 2 ** (k - 1)
	if n % cur == 0:
		maxcur = cur
	k += 1
print(maxcur)


def isBeautiful(n):
	s = list(str(bin(n)))
	s = s[2:]
	a = len(s)
	if s == sorted(s, reverse=True) and a % 2 == 1 and (a >= 3) and (s[a // 2] == '1') and (s[a // 2 + 1] == '0'):
		return True
	else:
		return False
n = int(input())
result = False
for i in range(n, 0, -1):
	if n // i * i == n and isBeautiful(i):
		result = True
		print(i)
		break
if result == False:
	print('1')


def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))

def STRING():
	return input()
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter
from math import *
from itertools import permutations
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]

def f(n):
	d = ''
	while n > 0:
		x = n % 2
		d += str(x)
		n //= 2
	return d[::-1]

def d(n):
	d = deque()
	i = 1
	while i * i <= n:
		if n % i == 0:
			if n // i == i:
				d.append(i)
			else:
				d += [i, n // i]
		i += 1
	return d

def check(s):
	r1 = s.find('1')
	r2 = s.rfind('1')
	cnt0 = 0
	cnt1 = 0
	s2 = list(s)
	for i in range(r1, r2 + 1):
		if s2[i] == '1':
			cnt1 += 1
		else:
			cnt0 += 1
	cnt02 = s.count('0')
	if cnt0 == 0 and cnt02 + 1 == cnt1:
		return True
	return False
n = INT()
r1 = d(n)
z = []
for i in r1:
	x = f(i)
	y = check(x)
	if y:
		z.append(i)
z = list(reversed(sorted(z)))
print(z[0])


def BeautifulDivisors(k):
	return int('1' * (k + 1) + '0' * k, 2)

def main():
	num = int(input())
	k = 0
	bd = 1
	res = bd
	while bd <= num:
		divsion = num / bd
		if int(divsion) == divsion:
			res = bd
		k += 1
		bd = BeautifulDivisors(k)
	return res
print(main())


def Check(s):
	if len(s) % 2 != 0:
		for i in range((len(s) - 1) // 2 + 1):
			if s[i] == '0':
				return False
		return True
	else:
		return False
n = int(input())
d = []
for i in range(1, n + 1):
	if n % i == 0:
		d.append(i)
for i in range(len(d) - 1, -1, -1):
	x = d[i]
	s1 = ''
	while x > 0:
		s1 = str(x % 2) + s1
		x //= 2
	if Check(s1) and s1.count('1') - 1 == s1.count('0'):
		print(d[i])
		break


import sys, math, queue, bisect
MOD = 10 ** 9 + 7
sys.setrecursionlimit(1000000)
n = int(input())
b = [1]
while b[-1] < n:
	k = len(b) + 1
	b.append(((1 << k) - 1) * (1 << k - 1))
b.reverse()
for bi in b:
	if n % bi == 0:
		print(bi)
		exit()


i = 1
k = 1
s = set()
while i <= 100000:
	i = (2 ** k - 1) * 2 ** (k - 1)
	s.add(i)
	k += 1
n = int(input())
mx = 1
for i in range(1, n + 1):
	if n % i == 0:
		if i in s:
			mx = i
print(mx)


def isBeautiful(num):
	for i in range(1, 100):
		currentPow = 2 ** (i - 1)
		if (currentPow * 2 - 1) * currentPow == num:
			return True
		if (currentPow * 2 - 1) * currentPow > num:
			return False
	return False
num = int(input())
max = -1
for i in range(1, num + 1):
	if num % i == 0 and isBeautiful(i):
		max = i
print(max)


num = int(input())
a = 0
b = 1 / 2
div = 0
result = -1
while div < num:
	a = int((a + 1) * 2 - 1)
	b = int(b * 2)
	div = a * b
	if num % div == 0:
		result = div
print(result)


n = int(input())
c = 1
for i in range(1, 20):
	tmp = (2 ** i - 1) * 2 ** (i - 1)
	if n % tmp == 0:
		c = tmp
print(c)


n = int(input())

def is_fine(num):
	tmp = num
	bit = 0
	k = 0
	while bit != 1:
		bit = num & 1
		num >>= 1
		k += 1
	return (2 ** k - 1) * 2 ** (k - 1) == tmp
for i in range(n, 0, -1):
	if n % i == 0 and is_fine(i):
		break
print(i)


n = int(input())
k = 0
x = n
while x % 2 == 0:
	x = x // 2
	k += 1
p = 1
for i in range(k + 1):
	x = 2 ** (i + 1) - 1
	y = 2 ** i
	if n % (x * y) == 0:
		p = x * y
print(p)


n = int(input())
s = 0
for i in range(n, 1, -1):
	if n % i == 0:
		bin1 = str(bin(i))
		bin1 = bin1[2:]
		if bin1[0] == '1' and bin1[len(bin1) - 1] == '0':
			k1 = 1
			for j in range(1, len(bin1)):
				if bin1[j] == '1' and bin1[j - 1] == '1':
					k1 += 1
			if k1 == bin1.count('1') and k1 - 1 == bin1.count('0'):
				print(i)
				s = 1
				break
if s != 1:
	print(1)


n = int(input())
k = 1
bn = 1
while True:
	bn = (2 ** k - 1) * 2 ** (k - 1)
	if bn > n:
		break
	if n % bn == 0:
		gd = bn
	k += 1
print(gd)
print('\n')


import itertools
import re
import math
import getpass
import sys
import string
debug = getpass.getuser() == 'frohe'
files = True
if debug and files:
	sys.stdin = open('test.in')
else:
	pass

def ria():
	return [int(i) for i in input().split()]
n = ria()[0]
ar = []
for i in range(1, 30):
	ar.append(int('1' * i + '0' * (i - 1), 2))
for i in reversed(ar):
	if n % i == 0:
		print(i)
		return


a = []
for i in range(1, 9):
	a.append((pow(2, i) - 1) * pow(2, i - 1))
b = int(input())
c = 1
for i in range(8):
	if b % a[i] is 0:
		c = a[i]
print(c)


import sys
n = int(sys.stdin.readline())
divlist = [32640, 8128, 2016, 496, 120, 28, 6, 1]
i = 0
while n < divlist[i]:
	i = i + 1
while n % divlist[i] != 0:
	i = i + 1
print(divlist[i])


from io import BytesIO, IOBase
import sys
import math
import os
from collections import defaultdict
from math import ceil
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def mint():
	return map(int, input().split())

def mfloat():
	return map(float, input().split())

def solve():
	n = int(input())
	ans = 1
	k = 2
	c = (2 ** k - 1) * 2 ** (k - 1)
	while c <= n:
		if n % c == 0:
			ans = c
		k += 1
		c = (2 ** k - 1) * 2 ** (k - 1)
	print(ans)

def main():
	t = 1
	for _ in range(t):
		solve()
main()


def check(n):
	b = bin(n)[2:]
	k = int(len(b) / 2) + 1
	return b[:k].count('1') == k and b[k:n].count('0') == k - 1
n = int(input())
output = 1
for j in range(1, n + 1):
	if n % j == 0 and check(j) == True:
		output = j
print(output)


from collections import deque as dq
n = int(input())
s = dq(['1'])
a = []
for _ in range(8):
	b = ''
	for i in s:
		b += i
	s.append('0')
	s.appendleft('1')
	a.append(int(b, 2))
ans = 0
for i in a:
	if n % i == 0:
		ans = i
print(ans)


from collections import defaultdict as dd
from collections import Counter as ccd
from itertools import permutations as pp
from itertools import combinations as cc
from random import randint as rd
from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq as hq
import math
mod = pow(10, 9) + 7

def inp(flag=0):
	if flag == 0:
		return list(map(int, input().strip().split(' ')))
	else:
		return int(input())
n = inp(1)
k = 1 + math.ceil(math.log2(n) / 2)
while k:
	num = ((1 << k) - 1) * (1 << k - 1)
	if n % num == 0:
		print(num)
		break
	k -= 1


beautiful = [1, 6, 28, 120, 496, 2016, 8128, 32640]
num = int(input())
for x in range(0, 8):
	if num % beautiful[7 - x] == 0:
		print(beautiful[7 - x])
		break


n = int(input())
k = bin(n).replace('0b', '')
if k == '1' * (len(k) // 2 + 1) + '0' * (len(k) // 2):
	print(n)
else:
	for x in range(n // 2, 0, -1):
		if n % x == 0:
			k = bin(x).replace('0b', '')
			if k == '1' * (len(k) // 2 + 1) + '0' * (len(k) // 2):
				print(x)
				break


def main():
	x = eval(input())
	list1 = []
	t = 0
	k = 1
	while t < x:
		t = (2 ** k - 1) * 2 ** (k - 1)
		list1.append(t)
		k += 1
	for i in list1:
		if x % i == 0:
			m = i
	print(m)
main()


a = []
ans = 1
poww = 1
for i in range(0, 20):
	ans = poww
	poww = poww * 2
	ans = ans * (poww - 1)
	a.append(ans)
n = int(input())
for i in range(0, 20):
	if a[i] <= n and n % a[i] == 0:
		ans = a[i]
print(ans)


vals = [1, 6, 28, 120, 496, 2016, 8128, 32640]
inp = int(input())
for i in range(7, -1, -1):
	if inp % vals[i] is 0:
		print(vals[i])
		break


import sys
sys.setrecursionlimit(100000000)
N = int(input())
k = 1
result = 1
while k <= N:
	check = (2 ** k - 1) * 2 ** (k - 1)
	if check > N:
		break
	if N % check == 0:
		result = max(check, result)
	k += 1
print(result)


n = int(input())
k = 1
num = 0
result = 1
while num <= 1000000.0:
	num = (pow(2, k) - 1) * pow(2, k - 1)
	if n % num == 0:
		result = num
	k += 1
print(result)


def divisor(k):
	return (2 ** k - 1) * 2 ** (k - 1)
k = int(input().strip().split()[0])
answer = 1
for i in range(1, k):
	if divisor(i) > k:
		break
	elif k % divisor(i) == 0:
		answer = divisor(i)
print(answer)


k = 1
cur = 1
i = int(input())
ret = 1
while cur <= i:
	k += 1
	if i % cur == 0:
		ret = cur
	cur = (2 ** k - 1) * 2 ** (k - 1)
print(ret)


n = []
for x in range(1, 10):
	n += [(2 ** x - 1) * 2 ** (x - 1)]
x = int(input())
k = []
for i in range(9):
	if x % n[i] == 0:
		k += [n[i]]
print(max(k))


n = int(input())
m = 1
for i in range(2, n + 2, 2):
	if n % i == 0:
		k = bin(i)[2:]
		u = k.count('1')
		z = k.count('0')
		if u == z + 1 and k[:u].count('0') == 0:
			m = i
print(m)


n = int(input())
for k in range(20, 0, -1):
	div = (2 ** k - 1) * 2 ** (k - 1)
	if n % div == 0:
		print(div)
		break


a = [((1 << i) - 1) * (1 << i - 1) for i in range(1, 9)]
s = int(input())
t = 0
for i in a:
	if s % i == 0:
		t = max(t, i)
print(t)


lubas_number = int(input())
divider = lubas_number - 1
lubas_bin = bin(lubas_number)[2:]

def if_consecutive(integer):
	binary = bin(integer)[2:]
	last_index = binary.rfind('1')
	if '0' in binary[:last_index + 1]:
		return False
	return True
if lubas_bin.count('1') - lubas_bin.count('0') == 1 and if_consecutive(lubas_number):
	divider = lubas_number
if divider != lubas_number:
	while divider != 1:
		if lubas_number % divider == 0:
			if if_consecutive(divider):
				ones = bin(divider)[2:].count('1')
				zeros = bin(divider)[2:].count('0')
				if ones - zeros == 1:
					break
		divider -= 1
print(divider)


def main():
	beautiful_numbers = [1, 6, 28, 120, 496, 2016, 8128, 32640]
	n = int(input())
	print(next((beautiful_numbers[i] for i in range(len(beautiful_numbers) - 1, -1, -1) if n % beautiful_numbers[i] == 0)))
main()


n = int(input())
k = n
if n % 2 != 0:
	print(1)
	exit()
while n >= 1:
	if k % n == 0:
		B = bin(n)[2:]
		if B.count('1') - B.count('0') == 1 and '01' not in str(B):
			print(n)
			exit()
	n -= 1


n = input('')
n = int(n)
beautiful_number = [1]
k = 1
while 1:
	now = ((1 << k) - 1) * (1 << k - 1)
	if now > 100000:
		break
	beautiful_number.append(now)
	k = k + 1
ans = 1
for i in beautiful_number:
	if n % i == 0:
		ans = i
print(ans)


n = int(input())
a = []
ans = 0
copy = n

def binary(a):
	ans = 0
	for i in range(len(a)):
		ans += a[len(a) - 1 - i] * 2 ** i
	return ans

def rindex(alist, value):
	return len(alist) - alist[-1::-1].index(value) - 1

def isTrue(a):
	return a.count(1) - 1 == a.count(0)
while n > 0:
	a.append(n % 2)
	n //= 2
a.reverse()
last = rindex(a, 1)
new_arr = sorted(a)
new_arr.reverse()
while new_arr.count(0) >= new_arr.count(1) and len(new_arr) > 1:
	new_arr.remove(0)
while new_arr.count(1) > new_arr.count(0) + 1 and len(new_arr) > 1:
	new_arr.remove(1)
while copy % binary(new_arr):
	if len(new_arr) > 1 and 0 in new_arr:
		new_arr.remove(0)
	if len(new_arr) > 1 and 1 in new_arr:
		new_arr.remove(1)
for i in range(len(new_arr)):
	ans += new_arr[len(new_arr) - 1 - i] * 2 ** i
print(ans)


n = int(input())
k = 1
ans = 0
while (2 ** k - 1) * 2 ** (k - 1) <= n:
	if n % (2 ** k - 1) == 0 and n % 2 ** (k - 1) == 0:
		ans = max(ans, (2 ** k - 1) * 2 ** (k - 1))
	k += 1
print(ans)


n = int(input())
k = 1
d = (2 ** k - 1) * 2 ** (k - 1)
gd = 1
while d <= n:
	l = d
	if n / d == int(n / d):
		gd = l
	d = (2 ** k - 1) * 2 ** (k - 1)
	k += 1
print(gd)


f = lambda k: (2 ** k - 1) * 2 ** (k - 1)
n = int(input())
c = 1
k = 1
while f(k) <= n:
	if n % f(k) == 0:
		c = f(k)
	k += 1
print(c)


k = 1
n = int(input())
res = 1

def f(x):
	return (2 ** x - 1) * 2 ** (k - 1)
k = res = 1
while f(k) < n:
	k += 1
	if n % f(k) == 0:
		res = f(k)
print(res)


n = int(input())
for i in range(n, 0, -1):
	if n % i != 0:
		continue
	bz = f'{i:b}'
	if bz.count('0') + 1 != bz.count('1'):
		continue
	elif set(bz[:len(bz) // 2 + 1]) == {'1'}:
		print(i)
		break


ar = [(pow(2, x) - 1) * pow(2, x - 1) for x in range(1, 100)]
n = int(input())
mx = 1
for x in ar:
	if n % x == 0:
		mx = x
print(mx)


import math
n = int(input())
ans = 1
for i in range(1, 100):
	k = int(pow(2, i * 2 + 1)) - int(pow(2, i))
	if n % k == 0:
		ans = k
	elif k > n:
		break
print(ans)


x = int(input())

def pow2(k):
	d = 1
	for z in range(k):
		d = d * 2
	return d
L = list()
L.append(1)
i = 3
j = 1
while j < 17:
	res = pow2(2 * j + 1) - pow2(j)
	L.append(res)
	j = j + 1
s = 0
r = 1
while L[s] <= x:
	if x % L[s] == 0:
		r = L[s]
	s = s + 1
print(r)


n = int(input())
p = 2
a = 1
while p < n:
	if n % (p * (p - 1) // 2) == 0:
		a = p
	p *= 2
if a == 1:
	print(1)
else:
	print((a - 1) * a // 2)


import sys
import math

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()

def FACT(n, mod):
	s = 1
	facts = [1]
	for i in range(1, n + 1):
		s *= i
		s %= mod
		facts.append(s)
	return facts[n]

def C(n, k, mod):
	return FACT(n, mod) * pow(FACT(k, mod) * FACT(n - k, mod) % mod, mod - 2, mod) % mod
n = II()
ans = 1
for i in range(1, n + 1):
	if n % i == 0:
		temp = n // i
		temp = list(bin(temp)[2:])
		l = len(temp)
		if l % 2 == 1 and temp == ['1'] * (l // 2 + 1) + ['0'] * (l // 2):
			ans = n // i
			break
print(ans)


def gbd(n):
	k = 0
	while (2 ** k - 1) * 2 ** (k - 1) < n:
		k += 1
	if (2 ** k - 1) * 2 ** (k - 1) == n:
		return n
	else:
		return 1
n = int(input())
bd = 1
for i in range(2, n + 1):
	if n % i == 0:
		if bd <= gbd(i):
			bd = gbd(i)
print(bd)


import math
n = int(input())
c = 1
good = 1
while c <= n:
	if n % c == 0:
		good = c
	c = (c + 2 ** (math.ceil(math.log(c, 2)) + (c == 1))) * 2
print(good)


from math import sqrt
n = int(input())
ks = set()
for i in range(1, int(sqrt(n)) + 2):
	if n % i == 0:
		ks.add(i)
		ks.add(n // i)
eksi1 = []
diger = []
for i in range(1, 11):
	eksi1.append(2 ** i - 1)
	diger.append(2 ** (i - 1))
ms = 1
for s in ks:
	for k in range(1, 11):
		if s % eksi1[k - 1] == 0 and s // eksi1[k - 1] == diger[k - 1]:
			ms = max(ms, eksi1[k - 1] * diger[k - 1])
print(ms)


n = int(input())
k = 1
flag = -1
while k <= 17:
	res = (2 ** k - 1) * 2 ** (k - 1)
	if n % res == 0:
		flag = max(flag, res)
	k += 1
print(flag)


n = int(input())
k = 1
prekrasnoe = 0
biggest = 0
while prekrasnoe <= n:
	prekrasnoe = (2 ** k - 1) * 2 ** (k - 1)
	k += 1
	if n % prekrasnoe == 0:
		biggest = prekrasnoe
print(biggest)


n = int(input())

def a(n):
	b = [1]
	k = 1
	while b[k - 1] <= n:
		b.append((2 ** k - 1) * 2 ** (k - 1))
		k += 1
	return b
c = a(n)
for i in range(len(c) - 1, -1, -1):
	if n % c[i] == 0:
		print(c[i])
		break


n = int(input())
count = 2
m = 1
z = m
while z < n:
	z = (2 ** count - 1) * 2 ** (count - 1)
	if n % z == 0:
		m = z
	count += 1
print(m)


n = int(input())
a = n
if n % 2 == 1:
	print(1)
else:
	k = 0
	while n % 2 == 0:
		n /= 2
		k += 1
	while k >= 0:
		if a % ((1 << k) * ((1 << k + 1) - 1)) == 0:
			print((1 << k) * ((1 << k + 1) - 1))
			break
		else:
			k -= 1


n = int(input())
for k in range(1, 9):
	d = 2 ** k - 1
	f = 2 ** (k - 1)
	g = d * f
	if n % g == 0:
		ma = g
print(ma)


n = int(input())
maximum = 1
k = 1
while 2 ** (k - 1) * (2 ** k - 1) <= n:
	if n % (2 ** (k - 1) * (2 ** k - 1)) == 0:
		maximum = 2 ** (k - 1) * (2 ** k - 1)
	k += 1
print(maximum)


t = int(input())
m = 1
x = 1
sum = 1
while m * x <= t:
	y = x * m
	if t % y == 0:
		sum = y
	m *= 2
	x = x * 2 + 1
print(sum)


def solve(n):
	maxx = len(bin(n)[2:])
	if not maxx & 1:
		maxx -= 1
	while maxx > 1:
		beaut = int('1' * (maxx // 2 + 1) + '0' * (maxx // 2), 2)
		if n % beaut == 0:
			return beaut
		maxx -= 2
	return 1
print(solve(int(input())))


def make(s):
	co = 0
	for i in range(len(s)):
		if int(s[len(s) - i - 1]):
			co += 2 ** i
	return co
arr = []
for i in range(13):
	s = '1' * (i + 1) + '0' * i
	arr.append(make(s))
arr = arr[::-1]
n = int(input())
for i in arr:
	if n % i == 0:
		print(i)
		break


num = int(input())
lista = []
for i in range(1, 32):
	lista.append((2 ** i - 1) * 2 ** (i - 1))
ans = 1
i = 0
while lista[i] <= num:
	if num % lista[i] == 0:
		ans = max(ans, lista[i])
	i += 1
print(ans)


Input = lambda : map(int, input().split())

def cal(num):
	s = bin(num)
	s = s.replace('0b', '')
	k = len(s)
	if k % 2 != 0 and s[:k // 2 + 1] == '1' * (k // 2 + 1) and (s[k // 2 + 1:] == '0' * (k - (k // 2 + 1))):
		return True
	else:
		return False

def divisor(n):
	yield n
	yield (n // 2)
	n //= 2
	while n != 0:
		n -= 1
		yield n
n = int(input())
for i in divisor(n):
	if n % i == 0:
		if cal(i):
			print(i)
			break


l = [0] * 10 ** 5
for i in range(1, 100):
	l[i] = (2 ** i - 1) * 2 ** (i - 1)
n = int(input())
ans = 0
for i in range(1, 100):
	if n % l[i] == 0:
		ans = l[i]
print(ans)


def divisors(n):
	count = -1
	for i in range(1, 15):
		temp = ((2 << i - 1) - 1) * ((2 << i - 1) // 2)
		if n % temp == 0:
			count = temp
	return count
print(divisors(int(input())))


def main():
	n = int(input())
	bm = []
	k = 2
	while True:
		num = (2 ** k - 1) * 2 ** (k - 1)
		bm.append(num)
		if num >= n:
			break
		k += 1
	for i in range(n, 5, -1):
		if n % i == 0 and i in bm:
			return i
	return 1
print(main())


x = [1, 6, 28, 15 * 8, 31 * 16, 63 * 32, 127 * 64, 255 * 128]
n = int(input())
i = len(x) - 1
while n % x[i] != 0:
	i -= 1
print(x[i])


n = int(input())
import math
div = []
for i in range(1, n + 1):
	if n % i == 0:
		div.append(i)
x = [str(bin(i)[2:]) for i in div]
y = []
for i in x:
	if len(i) % 2 == 1:
		if '1' * math.ceil(len(i) / 2) == i[:math.ceil(len(i) / 2)] and '0' * math.floor(len(i) / 2) == i[math.ceil(len(i) / 2):]:
			y.append(int(i, 2))
print(max(y))


a = [1, 6, 28, 120, 496, 2016, 8128, 32640, 130816, 523776, 2096128, 8386560]
n = int(input())
for i in range(len(a) - 1, -1, -1):
	if n % a[i] == 0:
		print(a[i])
		break


x = []
k = 2
num = 1
x.append(1)
while num <= 100000:
	num = (2 ** k - 1) * 2 ** (k - 1)
	x.append(num)
	k = k + 1
z = int(input())
j = 0
max = -1
while x[j] <= z:
	if z % x[j] == 0 and x[j] > max:
		max = x[j]
	j = j + 1
print(max)


n = int(input())
s = '{0:b}'.format(n)
l = len(s)
for k in range(int(l / 2), -1, -1):
	b = ''.join(['1'] * (k + 1) + ['0'] * k)
	n2 = int(b, 2)
	if n2 <= n and n % n2 == 0:
		print(n2)
		break


def beau(x):
	com = 0
	while x % 2 == 0:
		x = x // 2
		com += 1
	if x == 2 ** (com + 1) - 1:
		return True
	else:
		return False
n = int(input())
for i in range(n, 0, -1):
	if beau(i) and n % i == 0:
		print(i)
		break


n = int(input())
l = []
for i in range(1, 12):
	y = ''
	for j in range(1, i + 1):
		y += '1'
	for j in range(1, i):
		y += '0'
	l.append(int(y, 2))
for i in range(len(l) - 1, -1, -1):
	if n % l[i] == 0:
		print(l[i])
		break


import sys, bisect
n = int(sys.stdin.readline())
ans = 0
for i in range(10):
	temp = '1' * (i + 1) + '0' * i
	if n % int(temp, base=2) == 0:
		ans = int(temp, base=2)
print(ans)


a = [(pow(2, k) - 1) * pow(2, k - 1) for k in range(1, 15)]
a = a[::-1]
n = int(input())
for i in a:
	if n % i == 0:
		print(i)
		break


n = int(input())
bin_ = bin(n)
t = len(bin_) - 2
l = t // 2
while True:
	if n % (2 ** (2 * l + 1) - 2 ** l) == 0:
		print(2 ** (2 * l + 1) - 2 ** l)
		break
	l = l - 1


n = int(input())
k = 1
ans = 1
while 2 ** k < n:
	if n % ((2 ** k - 1) * 2 ** (k - 1)) == 0:
		ans = (2 ** k - 1) * 2 ** (k - 1)
	k += 1
print(ans)


def encontraDivisor(numero):
	k = 1
	divisor = 0
	maior_divisor = 1
	while divisor <= numero:
		divisor = (pow(2, k) - 1) * pow(2, k - 1)
		resto = numero % divisor
		if resto == 0:
			if divisor >= maior_divisor:
				maior_divisor = divisor
		k = k + 1
	return maior_divisor
numero = int(input())
numero = encontraDivisor(numero)
print(numero)


n = int(input())
for i in range(n):
	y = (1 << i + 1) - 1 << i
	if y > n:
		break
	if n % y < 1:
		x = y
print(x)


(n, k, c, v) = (int(input()), 1, 1, 0)
while c <= n:
	if n % c == 0:
		v = c
	k += 1
	c = (2 ** k - 1) * 2 ** (k - 1)
print(v)


n = int(input())
k = 1
l = list()
l.append(int('1' * k + '0' * (k - 1), 2))
while l[k - 1] < 100000:
	k += 1
	l.append(int('1' * k + '0' * (k - 1), 2))
i = len(l) - 1
while n % l[i] != 0:
	i -= 1
print(l[i])


import math

def pretty_numbers():
	k = 1
	while True:
		yield ((2 ** k - 1) * 2 ** (k - 1))
		k += 1
a = []
for i in pretty_numbers():
	if i > 10 ** 5:
		break
	else:
		a.append(i)
x = int(input())
for i in a[::-1]:
	if x % i == 0:
		print(i)
		break


n = int(input())
a = [0] * 23
for i in range(0, 23):
	a[i] = (2 ** (i + 1) - 1) * 2 ** i
for i in range(22, -1, -1):
	if n % a[i] == 0:
		print(a[i])
		break


beautiful = [(2 ** k - 1) * 2 ** (k - 1) for k in range(11)]
beautiful.reverse()
N = int(input())
for i in beautiful:
	if N % i == 0:
		print(i)
		exit()


n = int(input())
b = [1, 6, 28, 120, 496, 2016, 8128, 32640]
x = 0
big = 0
while n % b[7 - x] != 0:
	x = x + 1
print(b[7 - x])


l = []
for k in range(1, 20):
	l.append((2 ** k - 1) * 2 ** (k - 1))
x = int(input())
l.reverse()
for i in l:
	if x % i == 0:
		print(i)
		quit()


x = [1, 6, 28, 120, 496, 2016, 8128, 32640]
y = int(input())
max = 1
for i in range(0, len(x)):
	if y >= x[i] and y % x[i] == 0 and (x[i] > max):
		max = x[i]
print(max)


l = []
(i, j) = (1, 0)
while True:
	s = '1' * i + '0' * j
	f = int(s, 2)
	if f > 100000:
		break
	l.append(f)
	i += 1
	j += 1
n = int(input())
if n % 2 == 1:
	print(1)
else:
	x = -1
	for k in l:
		if n % k == 0:
			x = k
	if x == -1:
		print(1)
	else:
		print(x)


n = int(input())
dr = 0
dt = 1
de = 8192
r = ''
maxi = 0
d = []
d2 = []
for i in range(1, n + 1):
	if n % i == 0:
		d.append(i)
		d2.append('')
for i in range(len(d)):
	t = d[i]
	while d[i] != 0:
		d2[i] += str(d[i] % 2)
		d[i] //= 2
	for j in range(len(d2[i]) - 1, -1, -1):
		r += d2[i][j]
	d2[i] = r
	r = ''
	d[i] = t
for i in range(len(d2)):
	j = 0
	k = 0
	d2[i] = d2[i][d2[i].find('1'):]
for i in range(len(d2)):
	if len(d2[i]) % 2 != 0:
		dr = len(d2[i]) // 2 + 1
		dt = len(d2[i]) // 2
	if '1' * dr + '0' * dt == d2[i]:
		maxi = i
print(d[maxi])