def qwe(x):
if x < 2:
return False
if x == 2:
return True
if x % 2 == 0:
return False
for i in range(3, int(x ** 0.5) + 1, 2):
if x % i == 0:
return False
return True
num=[[]for i in range(10001) ]
num2=[]
for i in range(2,10000):
for j in range(2,10000-i):
if qwe(i) and qwe(j):
s=i+j
if s%2==0:
num[s].append([i,j])
for i in range(len(num)):
if num[i]!=[]:
num2.append(num[i][0][0])
print(max(num2))