#include #include #include #include #include #include #include #include #include #include #include int main() { int V[4] = {}; int min = 0; for (auto& v : V) { std::cin >> v; min += v; } for (auto A = 1; A <= 30; ++A) { for (auto B = A + 1; B <= 30; ++B) { for (auto C = B + 1; C <= 30; ++C) { int dp[31] = {}; for (auto& d : dp) { d = 120; } dp[0] = 0; for (int i = 0; i < 30; ++i) { if (i + A <= 30) { dp[i + A] = std::min(dp[i + A], dp[i] + 1); } if (i + B <= 30) { dp[i + B] = std::min(dp[i + B], dp[i] + 1); } if (i + C <= 30) { dp[i + C] = std::min(dp[i + C], dp[i] + 1); } } int s = 0; for (auto v : V) { s += dp[v]; } min = std::min(min, s); } } } std::cout << min << std::endl; }