x,y,z,b=map(int,input().split()) print(max([x+y+z+b,x*3,y*3,z*3]))