A1,A2,A3,B = map(int ,input().split()) maxdamage = 0 k = A3*3 c = A1 + A2 + A3 + B if k > c: maxdamage = k else: maxdamage = c print(maxdamage)