#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-8;
typedef long long ll;

int main()
{
	int a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f
		, a || b || c || d || e || f)
	{
		int x, y, z;
		x = a + d;
		y = b + e;
		z = c + f;

		int ans = 0;
		for (int i = 0; i <= min(2, min(x, min(y, z))); ++i)
			ans = max(ans, i + (x-i)/3 + (y-i)/3 + (z-i)/3);
//			 + min((x-i)%3, min((y-i)%3, (z-i)%3)));

		cout << ans << endl;
	}

	return 0;
}