/*
  AOJ 1077
  Title:
  @kankichi573
*/
#include <stdio.h>
#define max(x,y) (((x)>(y))?(x):(y))

/*
    Math
    Greedy
    Geometry
    DP
    Graph
    Other
*/

int n[6];

int solve(int x1,int x2,int x3)
{
  // printf("X123=%d %d %d\n",x1,x2,x3);

  int r1,r2,r3,r4;
  r1=r2=r3=r4=0;
  if(!(x1>0 && x2>0 && x3>0) && x1<3 && x2<3 && x3<3)
    return(0);
  if(x1>=3)
    r1=1+solve(x1-3,x2,x3);
  if(x2>=3)
    r2=1+solve(x1,x2-3,x3);
  if(x3>=3)
    r2=1+solve(x1,x2,x3-3);
  if(x1>0 && x2>0 && x3>0)
    r4=1+solve(x1-1,x2-1,x3-1);
  return(max(max(r1,r2),max(r3,r4)));
}
main()
{
  int ret;

  while(scanf("%d %d %d %d %d %d",&n[0],&n[1],&n[2],&n[3],&n[4],&n[5]) &&
	(n[0]||n[1]||n[2]||n[3]||n[4]||n[5]||n[6]))
    {
      ret=solve(n[0]+n[3],n[1]+n[4],n[2]+n[5]);
      printf("%d\n",ret);
    }
  return(0);
}