#include<stdio.h>
int main(){
  int a,b,c,d,e,f,s;
  while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f),a|b||c||d||e||f){
    a+=d;
    b+=e;
    c+=f;
    s=a/3;
    a%=3;
    s+=b/3;
    b%=3;
    s+=c/3;
    c%=3;
    while(a&&b&&c){
      s++;
      a--;
      b--;
      c--;
    }
    printf("%d\n",s);
  }
  return 0;
}