a1,a2,a3,b=map(int,input().split()) ans=a1+a2+a3+b A=[a1,a2,a3] for a in A: if a*3>ans: ans=a*3 print(ans)