A1, A2, A3, B = map(int, input().split()) print(max(A1 + A2 + A3 + B, A3 * 3))