var arr = readline().split(" ").map(Number);
var sum = 0;
var str = arr.join();
while (str !== '0,0,0,0,0,0') {
sum += arr[5] + arr[4] + arr[3] + Math.ceil(arr[2] / 4);
//差的个数
var dis2 = arr[1] - arr[3] * 5 //可能为负
var dis1 = arr[0] - arr[4] * 11
arr[1] = diss2 > 0 ? diss2 : 0;
arr[0] = dis1 > 0 ? dis1 : 0;
if (arr[1] == 0) {//2填充4箱子填完了不够,需要让1去填
arr[0] = arr[0]+dis2*4 > 0 ? arr[0]+dis2*4 : 0;
}
//需要填补的3字格
var dis = (4 - arr[2] % 4);
if (dis === 3) {
if (arr[1] > 5) {
sum += Math.ceil((arr[1] - 5) * 4 / 36);
arr[0] = (arr[0] - 7) > 0 ? (arr[0] - 7) : 0;
sum += Math.ceil(arr[0] / 36);
} else {
var disTemp = 27 - arr[1] * 4 ;
arr[0] = (arr[0] - disTemp) > 0 ? (arr[0] - disTemp) : 0;
sum += Math.ceil(arr[0] / 36);
}
}
if (dis === 2) {
if (arr[1] > 3) {
sum += Math.ceil((arr[1] - 3) * 4 / 36);
arr[0] = (arr[0] - 6) > 0 ? (arr[0] - 6) : 0;
sum += Math.ceil(arr[0] / 36);
} else {
var disTemp = 18 - arr[1] * 4 ;
arr[0] = (arr[0] - disTemp) > 0 ? (arr[0] - disTemp) : 0;
sum += Math.ceil(arr[0] / 36);
}
}
if (dis === 1) {
if (arr[1] > 1) {
sum += Math.ceil((arr[1] - 1) * 4 / 36);
arr[0] = (arr[0] - 5) > 0 ? (arr[0] - 5) : 0;
sum += Math.ceil(arr[0] / 36);
} else {
var disTemp = 9 - arr[1] * 4 ;
arr[0] = (arr[0] - disTemp) > 0 ? (arr[0] - disTemp) : 0;
sum += Math.ceil(arr[0] / 36);
}
}
print(result);
arr = readline().split(" ").map(Number);
str = arr.join();
}
#搜狐#