def solve(): A1,A2,A3,B=map(int,input().split()) return max(3*A3,A1+A2+A3+B) #================================================== print(solve())