a, b, c, d = [int(input()) for _ in range(4)]
t = min(map(abs, [a + b - c, a + c - b, b + c - a]))
print(max(0, t - d))
m = sorted([int(input()) for i in range(3)] + [0])
d = int(input())
l = -1
r = abs(2 * m[-1] - sum(m))
while r - l > 1:
m[0] = (l + r) // 2
for mask in range(16):
s = 0
for i in range(4):
if mask & 1 != False:
s += m[i]
else:
s -= m[i]
mask >>= 1
if d >= s >= -d:
r = m[0]
break
else:
l = m[0]
print(r)