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