#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair i_ll; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int u, v; ll w; }; ll MOD = 1000000007; ll _MOD = 1000000009; double EPS = 1e-10; int main() { vector V(4); cin >> V[0] >> V[1] >> V[2] >> V[3]; int mini = INT_MAX; for (int A = 1; A <= 30; A++) for (int B = A + 1; B <= 30; B++) for (int C = B + 1; C <= 30; C++) { vector a(31, INT_MAX / 10); a[0] = 0; for (int i = 1; i <= 30; i++) { if (i >= A) a[i] = min(a[i], a[i - A] + 1); if (i >= B) a[i] = min(a[i], a[i - B] + 1); if (i >= C) a[i] = min(a[i], a[i - C] + 1); } int sum = 0; for (int j = 0; j < 4; j++) sum += a[V[j]]; mini = min(mini, sum); } cout << mini << endl; }