#!/bin/python3

import math
import os
import random
import re
import sys



if __name__ == '__main__':
    arr = []

    for _ in range(6):
        arr.append(list(map(int, input().rstrip().split())))
        
sumList=[]
for i in range(4):
    for j in range(1,5):
        sum=0
        sum+=arr[i][j]
        sum+=arr[i][j-1] + arr[i][j+1]
        sum+=arr[i+1][j] + arr[i+2][j]    
        sum+=arr[i+2][j-1] + arr[i+2][j+1]
        sumList.append(sum)
                                                
print(max(sumList))
                
                
                
                
                
