#include <stdio.h>

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

int main(void)
{
    int i, s;
    int n[6], g[3];
    int a1, a2;
    
    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];
        }
        
        s = 0;
        while (g[0] - 3 >= 0 && g[1] - 3 >= 0 && g[2] - 3 >= 0){
            s += 3;
            g[0] -= 3; g[1] -= 3; g[2] -= 3;
        }
        a1 = s + g[0] / 3 + g[1] / 3 + g[2] / 3 + min(g[0] % 3, min(g[1] % 3, g[2] % 3));
        i = min(g[0], min(g[1], g[2]));
        a2 = s + i + (g[0] - i) / 3 + (g[1] - i) / 3 + (g[2] - i) / 3;
        
        printf("%d\n", max(a1, a2));
    }
    
    return (0);
}