a,b,c,d = map(int,input().split()) print(max(a+b+c+d,c*3))