a1,a2,a3,b = map(int,input().split()) print(max(a1+a2+a3+b,max(a1,a2,a3)*3))