MAX = 31 A = 0 B = 0 C = 0 DP = [] def solve(length): if length == 0: return 0 if length < 0: return float('inf') if 0 <= DP[length]: return DP[length] DP[length] = 1 + min(min(solve(length-A), solve(length-B)), solve(length-C)) return DP[length] boards = list(map(int, input().split(' '))) solution = sum(boards) for A in range(1, MAX): for B in range(1, MAX): for C in range(1, MAX): DP = [-1] * MAX solution = min(solution, solve(boards[0])+solve(boards[1])+solve(boards[2])+solve(boards[3])) print(solution)