a,b,c,n=map(int,input().split()) print(max(sum([a,b,c,n]),c*3))