A1, A2, A3, B = map(int, input().strip().split(' ')) X = sum([A1, A2, A3, B]) Y = A3 * 3 print(max(X, Y))