inf = open("stars.in", "r")
ouf = open("stars.out", "w")

a, b, c, d, e = map(int, inf.readline().split())

minV = b - a + 1
maxV = 0

z = [False] * (b + 1)
for i in range(0, b - a + 2):
    left = i
    for j in range(a, b + 1):
        z[j] = False
    for j in range(a, c - e):
        z[j] = True
        left -= 1
    for j in range(c - d + 1, min(c, b + 1)):
        z[j] = True
        left -= 1
    if left < 0:
        continue
    for j in range(a, b + 1):
        if left > 0 and not z[j] and j != c - e and j != c - d:
            z[j] = True
            left -= 1
    if left != 0:
        continue
    minV = min(minV, i)
    maxV = max(maxV, i)

print(minV, maxV, file=ouf)
        


inf.close()
ouf.close()