a1, a2, a3, b = map(int, input().split()) print(max(a1 + a2 + a3 + b, a3 * 3))