import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto ts = readln.split.to!(long[]);
    auto I = ts[0];
    auto O = ts[1];
    auto T = ts[2];
    auto J = ts[3];
    auto L = ts[4];
    auto S = ts[5];
    auto Z = ts[6];

    long K = O;

    auto i = I;
    auto l = min(J, L);

    K += i/2*2;
    if (i%2 == 1 && l > 0) {
        K += 3;
        l -= 1;
    }
    K += l*2;

    writeln(K);
}