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] * 2;
	a[1] = 0;

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

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

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

	long add = 0;

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

	return res + add;
}

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