#include #define REP(i, x, n) for(int i = x; i < (int)(n); i++) #define rep(i, n) REP(i, 0, n) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define F first #define S second #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair P; int main() { // ios_base::sync_with_stdio(false); int v0, v1, v2, v3; cin >> v0 >> v1 >> v2 >> v3; int ans = 10000; REP(A, 1, 31) REP(B, A + 1, 31) REP(C, B + 1, 31) { vector v{A, B, C}; vector dp(31, 10000); dp[0] = 0; rep(i, 3) rep(j, 31) if(dp[j] != 10000 && j + v[i] < 31) { dp[j + v[i]] = min(dp[j + v[i]], dp[j] + 1); } ans = min(ans, dp[v0] + dp[v1] + dp[v2] + dp[v3]); } cout << ans << endl; return 0; }