from typing import List def main(): vi = list(map(int, input().split())) vi.sort() maxV = vi[-1] r = float('inf') for a in range(1, maxV + 1): for b in range(a, maxV + 1): for c in range(b, maxV + 1): d = calc(vi, [a, b, c]) if d > 0: r = min(r, d) print(r) def calc(vi: List[int], ai: List[int]) -> int: dp = [-1] * (vi[-1] + 1) dp[0] = 0 def updateDp(dp: List[int], i: int, a: int) -> int: if i >= a and dp[i - a] >= 0: return dp[i - a] + 1 else: return -1 for i in range(1, len(dp)): a = [updateDp(dp, i, a) for a in ai] a = list(filter(lambda x: x >= 0, a)) if len(a) > 0: dp[i] = min(a) ci = [dp[v] for v in vi] if all([a >= 0 for a in ci]): return sum(ci) else: return -1 if __name__ == '__main__': main()