#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, e, f, ans;
int main()
{
int c31[4] = {0, 7, 6, 5}, c32[4] = {0, 5, 3, 1};
while (cin >> a >> b >> c >> d >> e >> f)
{
if (!(a || b || c || d || e || f))
break;
ans = d + e + f;
ans += c / 4;
if (c %= 4)
ans++;
// 把3、4、5、6全体装箱
int k2 = d * 5 + c32[c];
if (b > k2)
{
ans += (b - k2) / 9;
if ((b - k2) % 9)
ans++;
}
int k1 = ans * 36 - b * 4 - c * 9 - d * 16 - e * 25 - f * 36;
if (a > k1)
{
ans += (a - k1) / 36;
if ((a - k1) % 36)
ans++;
}
cout << ans << endl;
}
return 0;
}