#include<iostream>
#define SIZE 50000
using namespace std;
int newpacket(int a, int b, int c, int d,int e,int f){
int ans = 0;
int one = 0;
int two = 0;
ans += f;//装6*6的
ans += e;//装5*5的
one += e*11; //1*1还剩下的
ans += d;//装4*4的
two += d*5;//2*2还剩下的
int three = c/4;//装3*3的
int ttemp = c%4;//不满的
ans += ((ttemp==0)?three:(three+1)) ;
// 装了3个3*3就还可以装1个2*2 装了2个3*3就还可以装3个2*2 装了1个3*3就还可以装5个2*2
int ttwo = ((ttemp==0)? 0: (2*( 4 -ttemp)-1));//装了3剩下可装2的
two += ttwo;
//装了3个3*3就还可以装5个1*1 装了2个3*3就还可以装6个1*1 装了1个3*3就还可以装7个1*1
int tone = ((ttemp==0)? 0: (8 - ttemp));//装了3剩下可装2还剩下的可装1的
one += tone;
int tempb = 0;
if(b > two){ //装2*2
tempb = b -two;
int mytempb = tempb%9;
ans += ((mytempb==0)? (tempb/9):(tempb/9 +1));
//剩下每一个2*2的空位可以有4个1*1
one += ((mytempb==0)? 0: 4*(9-mytempb));
} else{
tempb = two - b;
one += 4* tempb;
}
int tempa = 0;
if(a > one){
tempa = a -one;
int mytempa = tempa%36;
ans += ((mytempa==0)?(tempa/36):(tempa/36 +1));
}else{
}
return ans;
}
int main(void){
int a,b,c,d,e,f;
while(cin>>a>>b>>c>>d>>e>>f){
if(a==0 && b==0 && c==0&&d==0&&e==0&&f==0)
return 0;
// cout<<packet(a,b,c,d,e,f)<<endl;
cout<<newpacket(a,b,c,d,e,f)<<endl;
}
// system("pause");
return 0;
}
#define SIZE 50000
using namespace std;
int newpacket(int a, int b, int c, int d,int e,int f){
int ans = 0;
int one = 0;
int two = 0;
ans += f;//装6*6的
ans += e;//装5*5的
one += e*11; //1*1还剩下的
ans += d;//装4*4的
two += d*5;//2*2还剩下的
int three = c/4;//装3*3的
int ttemp = c%4;//不满的
ans += ((ttemp==0)?three:(three+1)) ;
// 装了3个3*3就还可以装1个2*2 装了2个3*3就还可以装3个2*2 装了1个3*3就还可以装5个2*2
int ttwo = ((ttemp==0)? 0: (2*( 4 -ttemp)-1));//装了3剩下可装2的
two += ttwo;
//装了3个3*3就还可以装5个1*1 装了2个3*3就还可以装6个1*1 装了1个3*3就还可以装7个1*1
int tone = ((ttemp==0)? 0: (8 - ttemp));//装了3剩下可装2还剩下的可装1的
one += tone;
int tempb = 0;
if(b > two){ //装2*2
tempb = b -two;
int mytempb = tempb%9;
ans += ((mytempb==0)? (tempb/9):(tempb/9 +1));
//剩下每一个2*2的空位可以有4个1*1
one += ((mytempb==0)? 0: 4*(9-mytempb));
} else{
tempb = two - b;
one += 4* tempb;
}
int tempa = 0;
if(a > one){
tempa = a -one;
int mytempa = tempa%36;
ans += ((mytempa==0)?(tempa/36):(tempa/36 +1));
}else{
}
return ans;
}
int main(void){
int a,b,c,d,e,f;
while(cin>>a>>b>>c>>d>>e>>f){
if(a==0 && b==0 && c==0&&d==0&&e==0&&f==0)
return 0;
// cout<<packet(a,b,c,d,e,f)<<endl;
cout<<newpacket(a,b,c,d,e,f)<<endl;
}
// system("pause");
return 0;
}