#include #include #include #include #include #include #include #include #include #include #include const int MOD = 1e9 + 7; const int iINF = 1000000000; const long long int llINF = 1000000000000000000; #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long int; using P = pair; using edge = struct { int to; int cost; }; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int main() { vector V(4); rep(i, 4) cin >> V[i]; int ans = iINF; for (int A = 1; A < 31; A++) { for (int B = 1; B < 31; B++) { for (int C = 1; C < 31; C++) { vector dp(31, 999); dp[0] = 0; rep(i, 31 - A) { dp[i + A] = min(dp[i + A], dp[i] + 1); } rep(i, 31 - B) { dp[i + B] = min(dp[i + B], dp[i] + 1); } rep(i, 31 - C) { dp[i + C] = min(dp[i + C], dp[i] + 1); } int sum = 0; rep(i, 4) sum += dp[V[i]]; ans = min(ans, sum); } } } cout << ans << endl; return 0; }