#include "bits/stdc++.h" using namespace std; #define MAX 31 int main() { int V0, V1, V2, V3; cin >> V0 >> V1 >> V2 >> V3; int ans = 999; for (int A = 1; A < MAX; A++) { for (int B = A + 1; B < MAX; B++) { for (int C = B + 1; C < MAX; C++) { vector dp(MAX, 999); dp[0] = 0; for (int i = 0; i < MAX - A; i++) { dp[i + A] = min(dp[i + A], dp[i] + 1); } for (int i = 0; i < MAX - B; i++) { dp[i + B] = min(dp[i + B], dp[i] + 1); } for (int i = 0; i < MAX - C; i++) { dp[i + C] = min(dp[i + C], dp[i] + 1); } ans = min(ans, dp[V0] + dp[V1] + dp[V2] + dp[V3]); } } } cout << ans << endl; }