#!/bin/python3

import math
import os
import random
import re
import sys

def maxHourGlassSum(arr):
 
  max = arr[0][0] + arr[0][1]+arr[0][2] + arr[1][1]  +arr[2][0]  +arr[2][1] + arr[2][2]

  for i in range(0,4):

    j=0
    sum = 0
    while j<4:
      sum =arr[i][j]+arr[i][j+1] + arr[i][j+2]+arr[i+1][j+1] + arr[i+2][j]+arr[i+2][j+1]+arr[i+2][j+2]
      # print(f'{sum} of [{i}][{j}]')
      
      if(sum > max):
        max = sum 
      j+=1

  print(max)  


    
            

    

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

    for _ in range(6):
        arr.append(list(map(int, input().rstrip().split())))
    
    # print(arr[5][4])
    maxHourGlassSum(arr)