import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

long solve (long [] a)
{
	long a0 = min (a[0], 2);
	a[0] -= a0;

	long a3 = min (a[3], 2);
	a[3] -= a3;

	long a4 = min (a[4], 2);
	a[4] -= a4;

	long res = 0;

	res += a[1];
	a[1] = 0;

	res += (a[0] / 2) * 2;
	a[0] %= 2;

	res += (a[3] / 2) * 2;
	a[3] %= 2;

	res += (a[4] / 2) * 2;
	a[4] %= 2;

	long add = 0;

	add = max (add, ((a0 + a[0]) / 2) * 2 +
	    ((a3 + a[3]) / 2) * 2 + ((a4 + a[4]) / 2) * 2);

	if (a0 > 0 && a3 > 0 && a4 > 0)
	{
		add = max (add, 3 + ((a0 + a[0] - 1) / 2) * 2 +
	    ((a3 + a[3] - 1) / 2) * 2 + ((a4 + a[4] - 1) / 2) * 2);
	}

	if (a0 > 1 && a3 > 1 && a4 > 1)
	{
		add = max (add, 6 + ((a0 + a[0] - 2) / 2) * 2 +
	    ((a3 + a[3] - 2) / 2) * 2 + ((a4 + a[4] - 2) / 2) * 2);
	}

	return res + add;
}

void main ()
{
	long [] a;
	while ((a = readln.split.map !(to !(long)).array).length > 0)
	{
		writeln (solve (a));
	}
}
