#include using namespace std; int v[4]; int dp[32]; int f( int i, int j, int k){ for( int l=0;l<=30;l++)dp[l]=0x1fffffff-30; dp[0]=0; for( int l = 1;l<=30;l++){ if(i<=l)dp[l]=min(dp[l],dp[l-i]+1); if(j<=l)dp[l]=min(dp[l],dp[l-j]+1); if(k<=l)dp[l]=min(dp[l],dp[l-k]+1); } } int main(void){ cin>>v[0]>>v[1]>>v[2]>>v[3]; int res = 200; for(int i=1;i<=30;i++){ for(int j=i+1;j<=30;j++){ for(int k=j+1;k<=30;k++){ f(i,j,k); res = min(res, dp[v[0]]+dp[v[1]]+dp[v[2]]+dp[v[3]]); // for( int l = 0;l <= 30;l++)cout<