#include <cstdio>
#include <cstdlib>
#include <memory.h>
#include <vector>
using namespace std;

int a[12][12];
int aa[12][12];
long long best;

void brute(int v, long long cur) {
    if (cur > best) {
        best = cur;
    }
    for (int i = 0; i < 12; i++) {
        int add = aa[v][i];
        if (add > 0) {
            aa[v][i] /= 2;
            aa[i][v] /= 2;
            brute(i, cur + (add + 1) / 2);
            aa[v][i] = add;
            aa[i][v] = add;
        }
    }
}

int main() {
    freopen("coins.in", "r", stdin);
    freopen("coins.out", "w", stdout);
    for (int i = 0; i < 5; i++) {
        int ii = i / 2;
        if (i & 1) {
            for (int j = 0; j < 4; j++) {
                scanf("%d", &a[4 * ii + j][4 * (ii + 1) + j]);
                a[4 * (ii + 1) + j][4 * ii + j] = a[4 * ii + j][4 * (ii + 1) + j];
            }
        } else {
            for (int j = 0; j < 3; j++) {
                scanf("%d", &a[4 * ii + j][4 * ii + j + 1]);
                a[4 * ii + j + 1][4 * ii + j] = a[4 * ii + j][4 * ii + j + 1];
            }
        }
    }
    best = 0;
    for (int i = 0; i < 12; i++) {
        memcpy(aa, a, sizeof(a));
        brute(i, 0);
    }
    printf("%lld\n", best);
    return 0;
}
