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