#include using namespace std; int main(){ vector V(4); for(int i=0;i<4;i++) cin >> V[i]; int ans = 1000000000; for(int A=1;A<=30;A++){ for(int B=1;B<=30;B++){ for(int C=1;C<=30;C++){ int cnt = 0; for(int i=0;i<4;i++){ int Min = 10000000; for(int a=0;a<=30;a++){ for(int b=0;b<=30;b++){ int count = a+b; int res = V[i]-A*a-B*b; if(res < 0) break; if(res%C == 0){ count += res/C; Min = min(Min,count); } } } cnt += Min; } ans = min(ans,cnt); } } } cout << ans << endl; }