from sys import stdin
input=lambda :stdin.readline()[:-1]

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