#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<int> vi;

const int INF = 1e9;
const int MOD = 1e9+7;

int main(void){
    ll a, b, c, d, e, f;
	while(cin >> a >> b >> c >> d >> e >> f, a+b+c+d+e+f != 0){
        a += d;
        b += e;
        c += f;
        ll m = min(a, min(b, c));
        ll ans = 0;
        REP(i, 3){
            if(m - i < 0) continue;
            ll k = (a - i) / 3;
            k += (b - i) / 3;
            k += (c - i) / 3;
            ans = max(ans, k + i);
        }
        cout << ans << endl;
    }
	
	return 0;
}