A = list(map(int, input().split())) B = A[3] A = A[:3] print(max(sum(A) + B, 3 * max(A)))