import sys input = sys.stdin.readline a1, a2, a3, b = map(int, input().split()) a = [a1, a2, a3] ans = 0 for i in range(3): for j in range(3): for k in range(3): damage = a[i] + a[j] + a[k] if(i == 0 and j == 1 and k == 2): damage += b ans = max(ans, damage) print(ans)