var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var str=arr.shift();
   if(str=="0 0 0 0 0 0")break;
   var ary=str.split(" ").map(Number);
   var MD=ary[0]+ary[3];
   var GG=ary[1]+ary[4];
   var GO=ary[2]+ary[5];
   var cnt=0;
   if(MD>3){
      var x=(MD-(MD%3))/3;
      cnt+=x-1;
      MD=MD%3+3;
   }
   if(GG>3){
      var x=(GG-(GG%3))/3;
      cnt+=x-1;
      GG=GG%3+3;
   }
   if(GO>3){
      var x=(GO-(GO%3))/3;
      cnt+=x-1;
      GO=GO%3+3;
   }
   if(MD>=2 && GG>=2 && GO>=2){
      cnt+=2;
      MD-=2;
      GG-=2;
      GO-=2;
   }
   while(MD>=3){MD-=3;cnt++;}
   while(GG>=3){GG-=3;cnt++;}
   while(GO>=3){GO-=3;cnt++;}
   if(MD>=1 && GG>=1 && GO>=1)cnt++;
   console.log(cnt);
}