import sys input = sys.stdin.readline x,y,z,w=map(int,input().split()) print(max(max(x,y,z)*3,x+y+z+w))