min = 9*99
while 1:
a = int(input())
if a == 0:
break
elif a % 2 == 0:
if a < min:
min = a
if min == 9**9:
pass
else:
print(min)
min = 9*99
while 1:
a = int(input())
if a == 0:
break
elif a % 2 == 0:
if a < min:
min = a
if min == 9**9:
pass
else:
print(min)