#include<stdio.h>
int main (){
  int M, Gre, Geo, D, Gra, O;
  int count=0;
  while(1){
    scanf("%d%d%d%d%d%d",&M, &Gre, &Geo, &D, &Gra, &O);
    if(M == 0 && Gre == 0 && Geo == 0 && D == 0 && Gra == 0 && O == 0)break;
    if(M+D >= 3)count = count + (M+D)/3;
    if(Gre+Gra >= 3) count += (Gre+Gra)/3;
    if(Geo+O >= 3) count += (Geo+O)/3;
    if((M+D)-(M+D)%3 == 2 && (Gre+Gra)-(Gre+Gra)%3 == 2 && (Geo+O)-(Geo+O)%3 == 2)
      count += 2;
    else if((M+D)-(M+D)%3 >= 1 && (Gre+Gra)-(Gre+Gra)%3 >= 1 && (Geo+O)-(Geo+O)%3 >= 1)
      count += 1;
    else printf("0\n");
  
    printf("%d\n",count);
  }
  return 0;
}