a, b, c, d = map(int, input().split())
print(max(3 * max(a, b, c), a + b + c + d))