A1,A2,A3,B = map(int,input().split()) ans = max(A3*3 , A1+A2+A3+B) print (ans)