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

int n[6];

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

  if(x1>2)
    {
      r = x1/3;
      x1 %= 3;
    }
  if(x2>2)
    {
      r+=x2/3;
      x2 %= 3;
    }
  if(x3>2)
    {
      r+=x3/3;
      x3 %= 3;
    }
  r+=min(x1,min(x2,x3));
  return(r);
}
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);
}