a,b,c,d = map(int,input().split()) ans = a + b + d + c ans2 = 3 * c print(max(ans,ans2))