#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define mp make_pair #define mt make_tuple #define pb push_back #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair pii; const int INF = 1 << 29; const double EPS = 1e-9; const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; vector V; int dp[50]; int main() { for (int i = 0; i < 4; i++) { int x; cin >> x; V.push_back(x); } int res = INF; for (int A = 1; A <= 30; A++) { for (int B = A + 1; B <= 30; B++) { for (int C = B + 1; C <= 30; C++) { fill(dp, dp + 50, INF); dp[A] = 1; dp[B] = 1; dp[C] = 1; // cout << A << " " << B << " " << C << endl; for (int k = 1; k <= 30; k++) { if (k - A >= 0 and dp[k - A] != INF) { dp[k] = min(dp[k], dp[k - A] + 1); } if (k - B >= 0 and dp[k - B] != INF) { dp[k] = min(dp[k], dp[k - B] + 1); } if (k - C >= 0 and dp[k - C] != INF) { dp[k] = min(dp[k], dp[k - C] + 1); } } int tmp = 0; for (int i = 0; i < V.size(); i++) { tmp += dp[V[i]]; } res = min(res, tmp); } } } cout << res << endl; return 0; }