#include<stdio.h>
#include<algorithm>
int F(int a,int b,int c,int x)
{
	int r=0;
	if(a>=x&&b>=x&&c>=x)r=x,a-=x,b-=x,c-=x;
	return r+a/3+b/3+c/3+std::min(a%3,std::min(b%3,c%3));
}
int main()
{
	int a[6],i,x;
	for(;;)
	{
		for(i=x=0;i<6;++i)scanf("%d",a+i),x+=a[i];
		if(!x)return 0;
		for(i=0;i<3;++i)a[i]+=a[i+3];
		for(x=i=0;i<3;++i)x=std::max(x,F(*a,a[1],a[2],i));
		printf("%d\n",x);
	}
}