#include using namespace std; #define rep(i,n) for(int (i) = 0 ; (i) < (int)(n) ; (i)++) #define REP(i,a,b) for(int (i) = a ; (int)(i) <= (int)(b) ; (i)++) #define all(n) (n).begin(),(n).end() typedef vector Vi; typedef vector VVi; typedef pair Pii; typedef vector VPii; int main(){ int v[4]; rep(i,4) cin >> v[i]; int ans = 100000000; REP(i,1,30){ REP(j,1,30){ REP(k,1,30){ int dp[64] = {}; fill(dp,dp+64,100000000); dp[0] = 0; rep(l,32) dp[l+i] = min(dp[l+i],dp[l]+1); rep(l,32) dp[l+j] = min(dp[l+j],dp[l]+1); rep(l,32) dp[l+k] = min(dp[l+k],dp[l]+1); ans = min(ans,dp[v[0]]+dp[v[1]]+dp[v[2]]+dp[v[3]]); } } } cout << ans << endl; }