a = []
for n in range(1, 1001):
s = bin(n) [2:]
if s.count('1') % 2 == 0:
if s[1] == '0':
s = s[:1] + '1' + s[2:] + '1'
else:
s = s[:1] + '0' + s[2:] + '1'
else:
if s[-1] == '0':
s = '1' + s[:-1] + '1'
else:
s = '1' + s[:-1] + '0'
if s[-2] == '0':
s = '1' + s[:-2] + '1' + s[-1]
else:
s = '1' + s[:-2] + '0' + s[-1]
if int(s, 2) > 120:
a.append(n)
print(min(a))