v = list(map(int,input().split())) ans = float('inf') for a in range(1,31): for b in range(a,31): for c in range(b,31): dp = [float('inf')] * 31 dp[0] = 0 for i in range(30): if i + a <= 30: dp[i + a] = min(dp[i + a],dp[i] + 1) if i + b <= 30: dp[i + b] = min(dp[i + b],dp[i] + 1) if i + c <= 30: dp[i + c] = min(dp[i + c],dp[i] + 1) ans = min(ans,sum([dp[v[i]] for i in range(4)])) print(ans)