A = list(map(int, input().split(' '))) if sum(A[:4]) < max(A[:3]) * 3: print(max(A[:3]) * 3) else: print(sum(A[:4]))