#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f, a || b || c || d || e || f) {
		a += d; b += e; c += f;
		int Max = 0;
		for (int i = 0; i <= min(2, min(a, min(b, c))); i++)
			Max = max(Max, (a - i) / 3 + (b - i) / 3 + (c - i) / 3 + i);
		cout << Max << endl;
	}
}