#include <stdio.h>

#define max(a, b) ((a) > (b) ? (a) : (b))

int main(void)
{
    int i, j;
	int s;
    int n[6], g[3], c[3];
    int ans;
    while (1){
        s = 0;
        for (i = 0; i < 6; i++){
            scanf("%d", &n[i]);
            s += n[i];
        }
        
        if (s == 0){
            break;
        }
        
        for (i = 0; i < 3; i++){
            g[i] = n[i] + n[i + 3];
        }
		
		ans = 0;
		
		for (i = 0; i < 3; i++){
			for (j = 0; j < 3; j++){
				c[j] = g[j] - i;
				if (c[j] < 0){
					c[j] = -999999;
				}
			}
			ans = max(ans, i + c[0] / 3 + c[1] / 3 + c[2] / 3);
		}
		
		printf("%d\n", ans);
    }
    
    return (0);
}