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