#include<bits/stdc++.h> #define int long long #define ios ios::sync_with_stdio(0),cin.tie(0) usingnamespace std; int a,b,c,d,e,f;
signedmain(){ ios; while(cin>>a>>b>>c>>d>>e>>f){ if(a==0&&b==0&&c==0&&d==0&&e==0&&f==0)break; int ans = f+e+d; a = a - 11*e;//5*5可以用11個1*1填 b = b - 5*d;//一個4*4可以用5個2*2填 ans+=(c/4); if(c%4!=0)ans++; if(c%4==1){ a = a - 7; b = b - 5; } elseif(c%4==2){ a = a - 6; b = b - 3; } elseif(c%4==3){ a = a - 5; b = b - 1; } if(b>0){ ans+=(b/9); if(b%9!=0)ans++; a = a-(36-4*(b%9)); } elseif(b<0)a = a-(4*(-b));//如果b有欠,可以用a來補 if(a>0){ ans+=a/36; if(a%36!=0)ans++; } cout<<ans<<endl; } }