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