import sys input = sys.stdin.readline a1, a2, a3, b = map(int, input().split()) ans = max(a1 + a2 + a3 + b, a3 * 3) print(ans)