a, b, c, d=[int(i) for i in input().split()] first = a + b + c + d second = a*3 third = b*3 fourth = c*3 fifth = a*2 + b sixth = a + b*2 seventh = a*2 +c eighth = a + c*2 nineth = b + c*2 ten= b*2 +c select_damage =[first,second,third,fourth,fifth,sixth,seventh,eighth,nineth,ten] print(max(select_damage))