import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int[] space = new int[]{0, 5, 3, 1};
while(in.hasNext()) {
int[] packets = new int[6];
int check = 0;
for(int i = 0; i < 6; i++) {
packets[i] = in.nextInt();
check += packets[i];
}
if(check == 0) {
break;
}
int num = packets[5] + packets[4] + packets[3] + packets[2] / 4;
if(packets[2] % 4 != 0) {
num += 1;
}
int spaceForTwo = 5 * packets[3] + space[packets[2] % 4];
if(spaceForTwo < packets[1]) {
num += (packets[1] - spaceForTwo) / 9;
if((packets[1] - spaceForTwo) % 9 != 0) {
num += 1;
}
}
int spaceForOne = (num - packets[5]) * 36 - packets[4] * 25 - packets[3] * 16 - packets[2] * 9 - packets[1] * 4;
if(spaceForOne < packets[0]) {
num += (packets[0] - spaceForOne) / 36;
if((packets[0] - spaceForOne) % 36 != 0) {
num += 1;
}
}
System.out.println(num);
}
in.close();
}
}