a,b,o,w=map(int,input().split()) ans=0 if a: ans=max(ans,a+w) if b: ans=max(ans,b+w) if o: ans=max(ans,o+a+w,o+b+w) ans=max(ans,w) print(ans)