#include "bits/stdc++.h" using namespace std; #define print(x) cout< PI; typedef pair V; typedef vector VE; const ll mod = 1000000007; //10^9+7 int v[4]; int dp[32][4]; //dp[i][j],vjを使わないでiを作るのに何枚いるか int main(){ REP(i,4)cin>>v[i]; REP(i,32)REP(j,4)dp[i][j]=mod; REP(i,4)dp[0][i]=0; REP(i,32){ REP(k,4){ REP(j,4){ if(j==k||dp[i][k]==mod||i+v[j]>30)continue; dp[i+v[j]][k]=min(dp[i+v[j]][k],dp[i][k]+1); } } } //REP(i,32){cout<