while~0:s=input().split();[b+c in s==print(a+2*b+2*c+d)for a,b in s for c,d in s]