The final match of the Berland Football Cup has been held recently. The referee has shown $n$ yellow cards throughout the match. At the beginning of the match there were $a_1$ players in the first team and $a_2$ players in the second team.

The rules of sending players off the game are a bit different in Berland football. If a player from the first team receives $k_1$ yellow cards throughout the match, he can no longer participate in the match — he's sent off. And if a player from the second team receives $k_2$ yellow cards, he's sent off. After a player leaves the match, he can no longer receive any yellow cards. Each of $n$ yellow cards was shown to exactly one player. Even if all players from one team (or even from both teams) leave the match, the game still continues.

The referee has lost his records on who has received each yellow card. Help him to determine the minimum and the maximum number of players that could have been thrown out of the game.


-----Input-----

The first line contains one integer $a_1$ $(1 \le a_1 \le 1\,000)$ — the number of players in the first team.

The second line contains one integer $a_2$ $(1 \le a_2 \le 1\,000)$ — the number of players in the second team.

The third line contains one integer $k_1$ $(1 \le k_1 \le 1\,000)$ — the maximum number of yellow cards a player from the first team can receive (after receiving that many yellow cards, he leaves the game).

The fourth line contains one integer $k_2$ $(1 \le k_2 \le 1\,000)$ — the maximum number of yellow cards a player from the second team can receive (after receiving that many yellow cards, he leaves the game).

The fifth line contains one integer $n$ $(1 \le n \le a_1 \cdot k_1 + a_2 \cdot k_2)$ — the number of yellow cards that have been shown during the match.


-----Output-----

Print two integers — the minimum and the maximum number of players that could have been thrown out of the game.


-----Examples-----
Input
2
3
5
1
8

Output
0 4

Input
3
1
6
7
25

Output
4 4

Input
6
4
9
10
89

Output
5 9



-----Note-----

In the first example it could be possible that no player left the game, so the first number in the output is $0$. The maximum possible number of players that could have been forced to leave the game is $4$ — one player from the first team, and three players from the second.

In the second example the maximum possible number of yellow cards has been shown $(3 \cdot 6 + 1 \cdot 7 = 25)$, so in any case all players were sent off.

Difficulty: EASY
Tags: Mathematics

Implementation

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
h = a1 * k1
x = a2 * k2
total = a1 * k1 + a2 * k2
g = n
t = 0
if n >= total:
	print(a1 + a2, a1 + a2)
else:
	n = n - h - x + a2 + a1
	if k1 < k2:
		if h <= g:
			t = a1 + (g - h) // k2
		else:
			t = g // k1 + g % k1 // k2
		print(n if n > 0 else 0, t)
	else:
		if x <= g:
			t = a2 + (g - x) // k1
		else:
			t = g // k2 + g % k2 // k1
		print(n if n > 0 else 0, t)


I = lambda : int(input())
(a, b, k1, k2, n) = (I(), I(), I(), I(), I())
cnt = 0
(minim, maxim) = ([0, 0], [0, 0])
if k1 < k2:
	(m1, m2) = ([a, k1], [b, k2])
else:
	(m1, m2) = ([b, k2], [a, k1])
minimum = max(0, n - a * (k1 - 1) - b * (k2 - 1))
maximum = min(m1[0], n // m1[1])
maximum += (n - maximum * m1[1]) // m2[1]
print(minimum, maximum)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
ans_min = max(0, n - a1 * (k1 - 1) - a2 * (k2 - 1))
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
ans_max = min(a1, n // k1)
if ans_max == a1:
	n -= a1 * k1
	ans_max += n // k2
print(ans_min, ans_max)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
k = int(input())
maax = 0
c = k - a1 * (k1 - 1) - a2 * (k2 - 1)
if c < 0:
	man = 0
else:
	man = c
if k1 < k2:
	for j in range(a1):
		if k < k1:
			break
		k = k - k1
		maax = maax + 1
	for j in range(a2):
		if k < k2:
			break
		k = k - k2
		maax = maax + 1
else:
	for j in range(a2):
		if k < k2:
			break
		k = k - k2
		maax = maax + 1
	for j in range(a1):
		if k < k1:
			break
		k = k - k1
		maax = maax + 1
print(man, maax)


n1 = int(input())
n2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mini = 0
maxi = 0
p = n
if k1 < k2:
	maxi = n // k1
	if maxi <= n1:
		n = n - maxi * k1
	else:
		maxi = n1
		n = n - maxi * k1
	maxi += n // k2
else:
	maxi = n // k2
	if maxi > n2:
		maxi = n2
	n = n - maxi * k2
	maxi += n // k1
n = p
k11 = k1 - 1
k22 = k2 - 1
n = n - k11 * n1 - k22 * n2
if n > 0:
	mini = n
print(mini, maxi)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
a = n
minimum = [k2, a2] if k2 < k1 else [k1, a1]
maximum = [k2, a2] if k2 > k1 else [k1, a1]
cnt1 = 0
for el in range(minimum[1]):
	if a >= minimum[0]:
		a -= minimum[0]
		cnt1 += 1
for el in range(maximum[1]):
	if a >= maximum[0]:
		a -= maximum[0]
		cnt1 += 1
cnt = n - (a1 * (k1 - 1) + a2 * (k2 - 1))
print(0 if cnt < 0 else cnt, cnt1)


def mx(a1, a2, k1, k2, n):
	fst = min(n // k1, a1)
	n -= fst * k1
	scd = min(n // k2, a2)
	return fst + scd

def mn(a1, a2, k1, k2, n):
	n -= a1 * (k1 - 1) + a2 * (k2 - 1)
	return max(n, 0)
(a1, a2, k1, k2, n) = [int(input()) for _ in range(5)]
if k1 > k2:
	(a1, a2) = (a2, a1)
	(k1, k2) = (k2, k1)
print(mn(a1, a2, k1, k2, n), mx(a1, a2, k1, k2, n))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
minAns = min(max(0, n - ((k1 - 1) * a1 + (k2 - 1) * a2)), a1 + a2)
if k1 <= k2:
	minK = k1
	minA = a1
	maxK = k2
	maxA = a2
else:
	minK = k2
	minA = a2
	maxK = k1
	maxA = a1
maxAns = 0
maxAns += min(n // minK, minA)
n -= maxAns * minK
maxAns += min(n // maxK, maxA)
print(minAns, maxAns)


def solve(a1, a2, k1, k2, n):
	(minP, maxP) = (0, 0)
	p = min(n // k1, a1)
	r = n - p * k1
	q = min(r // k2, a2)
	maxP = p + q
	p = min(n // k2, a2)
	r = n - p * k2
	q = min(r // k1, a1)
	maxP = max(maxP, p + q)
	temp = a1 * (k1 - 1) + a2 * (k2 - 1)
	if temp >= n:
		minP = 0
	else:
		minP = n - temp
	return (minP, maxP)
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
(l, h) = solve(a1, a2, k1, k2, n)
print(str(l) + ' ' + str(h))


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import *
(a,) = I()
(b,) = I()
(x,) = I()
(y,) = I()
(n,) = I()
mx = 0
mn = MOD
for i in range(a + 1):
	for j in range(b + 1):
		if i * x + j * y <= n:
			mx = max(mx, i + j)
		if i * x + j * y <= n and (a - i) * (x - 1) + (b - j) * (y - 1) >= n - (i * x + j * y):
			mn = min(mn, i + j)
print(mn, mx)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())

def mn(a1, a2, k1, k2, n):
	n -= (k1 - 1) * a1 + (k2 - 1) * a2
	if n <= 0:
		return 0
	return min(n, a1 + a2)

def mx(a1, a2, k1, k2, n):
	if k1 > k2:
		(a1, a2) = (a2, a1)
		(k1, k2) = (k2, k1)
	if k1 * a1 >= n:
		return n // k1
	n -= k1 * a1
	return a1 + min(a2, n // k2)
print(mn(a1, a2, k1, k2, n), mx(a1, a2, k1, k2, n))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 > k2:
	(a1, a2, k1, k2) = (a2, a1, k2, k1)
dd = a1 * (k1 - 1) + a2 * (k2 - 1)
s = a1 + a2
if n <= dd:
	min_ = 0
else:
	min_ = n - dd
max_ = 0
y = True
while y:
	y = False
	if a1 > 0:
		if n >= k1:
			max_ += 1
			a1 -= 1
			n -= k1
			y = True
	elif a2 > 0:
		if n >= k2:
			max_ += 1
			a2 -= 1
			n -= k2
			y = True
print(str(min_) + ' ' + str(max_))


(A1, A2, K1, K2, N) = (int(input()), int(input()), int(input()), int(input()), int(input()))
All = A1 * (K1 - 1) + A2 * (K2 - 1)
print(min(A1 + A2, max(N - All, 0)), end=' ')
if K1 <= K2:
	Max = min(A1, N // K1)
	N -= Max * K1
	Max += min(A2, N // K2)
	print(Max)
else:
	Max = min(A2, N // K2)
	N -= Max * K2
	Max += min(A1, N // K1)
	print(Max)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
temp = n
temp = max(0, temp - a1 * (k1 - 1) - a2 * (k2 - 1))
minAns = temp
if k1 < k2:
	remove = min(a1, n // k1)
	n = n - remove * k1
	if n > 0:
		remove += min(a2, n // k2)
elif k2 <= k1:
	remove = min(a2, n // k2)
	n = n - remove * k2
	if n > 0:
		remove += min(a1, n // k1)
print(minAns, remove)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
ans = []
for i in range(a1 + 1):
	for j in range(a2 + 1):
		if i * k1 + j * k2 <= n:
			ans.append(i + j)
ans1 = max(ans)
c = (k1 - 1) * a1 + (k2 - 1) * a2
if n >= c:
	print(n - c, ans1)
else:
	print(0, ans1)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
m = 1 * n
(ans1, ans2) = (0, 0)
if k1 > k2:
	n -= a1 * (k1 - 1)
	if n > 0:
		n -= a2 * (k2 - 1)
	ans2 += min(a2, m // k2)
	m -= k2 * ans2
	if m > 0:
		ans2 += min(a1, m // k1)
elif k1 == k2:
	n -= (a1 + a2) * (k1 - 1)
	ans2 += min(a1 + a2, m // k1)
else:
	n -= a2 * (k2 - 1)
	if n > 0:
		n -= a1 * (k1 - 1)
	ans2 += min(a1, m // k1)
	m -= k1 * ans2
	if m > 0:
		ans2 += min(a2, m // k2)
if n > 0:
	ans1 += min(n, a1 + a2)
print(ans1, ans2)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
temp = n
x = 0
if k1 < k2:
	if n // k1 <= a1:
		x = n // k1
	else:
		x += a1
		n = n - a1 * k1
		x += n // k2
elif n // k2 <= a2:
	x = n // k2
else:
	x += a2
	n = n - a2 * k2
	x += n // k1
y = 0
temp = temp - (k1 - 1) * a1 - (k2 - 1) * a2
if temp > 0:
	y = min(temp, a1 + a2)
print(y, x, end=' ')


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
min2 = (k1 - 1) * a1 + (k2 - 1) * a2
if min2 < n:
	min1 = n - min2
else:
	min1 = 0
if k1 < k2:
	K1 = k1
	A1 = a1
	K2 = k2
	A2 = a2
else:
	K1 = k2
	A1 = a2
	K2 = k1
	A2 = a1
max1 = n // K1
max3 = 0
if max1 > A1:
	max1 = A1
	max2 = n - max1 * K1
	max3 = max2 // K2
	if max3 > A2:
		max3 = A2
print(min1, max1 + max3)


import sys
a1 = int(sys.stdin.readline())
a2 = int(sys.stdin.readline())
k1 = int(sys.stdin.readline())
k2 = int(sys.stdin.readline())
n = int(sys.stdin.readline())

def get_min():
	safe_upto = a1 * (k1 - 1) + a2 * (k2 - 1)
	if n <= safe_upto:
		return 0
	else:
		return min(n - safe_upto, a1 * k1 + a2 * k2 - safe_upto)

def get_max():
	rem_cards = n
	eliminated = 0
	if k1 > k2:
		eliminated += min(rem_cards // k2, a2)
		rem_cards -= eliminated * k2
		eliminated += min(rem_cards // k1, a1)
	else:
		eliminated += min(rem_cards // k1, a1)
		rem_cards -= eliminated * k1
		eliminated += min(rem_cards // k2, a2)
	return eliminated
print(get_min(), get_max())


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
p = a1 * (k1 - 1) + a2 * (k2 - 1)
if p >= n:
	print(0, end=' ')
else:
	print(n - p, end=' ')
s = 0
if k1 > k2:
	g = n // k2
	if g > a2:
		s += a2
		g = n - a2 * k2
		s += g // k1
		print(s)
	else:
		print(g)
else:
	g = n // k1
	if g > a1:
		s += a1
		g = n - a1 * k1
		s += g // k2
		print(s)
	else:
		print(g)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
x = a1 * (k1 - 1) + a2 * (k2 - 1)
m = 0
m = max(m, n - x)
if k1 > k2:
	(a1, a2) = (a2, a1)
	(k1, k2) = (k2, k1)
if n <= a1 * k1:
	print(m, n // k1)
else:
	print(m, a1 + (n - a1 * k1) // k2)


def mx(a1, a2, k1, k2, n):
	if a1 * k1 >= n:
		return n // k1
	else:
		return a1 + (n - a1 * k1) // k2

def mn(a1, a2, k1, k2, n):
	n1 = n - a1 * (k1 - 1) - a2 * (k2 - 1)
	if n1 > 0:
		return n1
	else:
		return 0

def solutionOnSorted(a1, a2, k1, k2, n):
	return (mn(a1, a2, k1, k2, n), mx(a1, a2, k1, k2, n))

def wrap(a1, a2, k1, k2, n):
	if k1 < k2:
		return solutionOnSorted(a1, a2, k1, k2, n)
	else:
		return solutionOnSorted(a2, a1, k2, k1, n)
(a, b) = wrap(int(input()), int(input()), int(input()), int(input()), int(input()))
print('{} {}'.format(a, b))


a = int(input())
a1 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
ma = a * k1 + a1 * k2
r = 0
p = 0
mi = a * (k1 - 1) + a1 * (k2 - 1)
if ma <= n:
	print(a + a1, a + a1)
else:
	if mi >= n:
		p = 0
	else:
		p = n - mi
	if k2 <= k1:
		while a1 and k2 <= n:
			n -= k2
			r += 1
			a1 -= 1
		if k1 <= n:
			r += n // k1
	else:
		while a and k1 <= n:
			n -= k1
			r += 1
			a -= 1
		if k2 <= n:
			r += n // k2
	print(p, r)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
temp1 = n - (k1 - 1) * a1 - (k2 - 1) * a2
temp2 = n
min_out = 0
max_out = 0
if k2 < k1:
	for i in range(a1):
		if temp1 - 1 < 0:
			break
		else:
			min_out += 1
			temp1 -= 1
	for j in range(a2):
		if temp1 - 1 < 0:
			break
		else:
			min_out += 1
			temp1 -= 1
	for j in range(a2):
		if temp2 - k2 < 0:
			break
		else:
			max_out += 1
			temp2 -= k2
	for i in range(a1):
		if temp2 - k1 < 0:
			break
		else:
			max_out += 1
			temp2 -= k1
else:
	for i in range(a2):
		if temp1 - 1 < 0:
			break
		else:
			min_out += 1
			temp1 -= 1
	for j in range(a1):
		if temp1 - 1 < 0:
			break
		else:
			min_out += 1
			temp1 -= 1
	for j in range(a1):
		if temp2 - k1 < 0:
			break
		else:
			max_out += 1
			temp2 -= k1
	for i in range(a2):
		if temp2 - k2 < 0:
			break
		else:
			max_out += 1
			temp2 -= k2
print(min_out, max_out)


F = lambda : int(input())
a1 = F()
a2 = F()
k1 = F()
k2 = F()
n = F()
(ma, mi) = (0, 0)
z = n
if min(k1, k2) == k1:
	m = min(a1, z // k1)
	ma += m
	z = max(0, z - k1 * m)
	ma += min(a2, z // k2)
else:
	m = min(a2, z // k2)
	ma += m
	z = max(0, z - k2 * m)
	ma += min(a1, z // k1)
t = a1 * (k1 - 1) + a2 * (k2 - 1)
if n > t:
	mi = min(a1 + a2, abs(n - t))
print(mi, ma)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 > k2:
	(a1, a2) = (a2, a1)
	(k1, k2) = (k2, k1)
lim = (k1 - 1) * a1 + (k2 - 1) * a2
mini = 0
maxi = 0
if n > lim:
	mini = n - lim
if n >= k1 * a1:
	n -= k1 * a1
	maxi += a1
else:
	rem = n // k1
	maxi += rem
	n -= rem * k1
rem = n // k2
maxi += rem
print(mini, maxi)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 > k2:
	(a1, k1, a2, k2) = (a2, k2, a1, k1)
mini = max(0, n - (k1 - 1) * a1 - (k2 - 1) * a2)
mt1 = min(n // k1, a1)
mt2 = (n - mt1 * k1) // k2
print(mini, mt1 + mt2)


(a1, a2, k1, k2, n) = [int(input()) for _ in range(5)]
(mi, ma) = (n - min(a1 * (k1 - 1) + a2 * (k2 - 1), n), 0)
if k1 <= k2:
	ma += min(n // k1, a1)
	n -= ma * k1
	ma += min(n // k2, a2)
else:
	ma += min(n // k2, a2)
	n -= ma * k2
	ma += min(n // k1, a1)
print(mi, ma)


def maxim(a1, a2, k1, k2, n):
	maximum = 0
	if k1 > k2:
		x = min(n // k2, a2)
		maximum += x
		n -= x * k2
		x = min(n // k1, a1)
		maximum += x
	else:
		x = min(n // k1, a1)
		maximum += x
		n -= x * k1
		x = min(n // k2, a2)
		maximum += x
	return maximum

def minim(a1, a2, k1, k2, n):
	minimum = 0
	if k1 > k2:
		n -= (k1 - 1) * a1
		n -= (k2 - 1) * a2
		if n > 0:
			x = min(n, a1)
			minimum += x
			n -= x
			if n > 0:
				x = min(n, a2)
				minimum += x
		else:
			return 0
	else:
		n -= (k2 - 1) * a2
		n -= (k1 - 1) * a1
		if n > 0:
			x = min(n, a2)
			minimum += x
			n -= x
			if n > 0:
				x = min(n, a1)
				minimum += x
		else:
			return 0
	return minimum
(a1, a2, k1, k2, n) = (int(input()), int(input()), int(input()), int(input()), int(input()))
print(minim(a1, a2, k1, k2, n), maxim(a1, a2, k1, k2, n))


a1 = int(input())
a11 = a1
a2 = int(input())
a22 = a2
k1 = int(input())
k2 = int(input())
n = int(input())
nn = n
Min = 0
if k1 > k2:
	n -= (k1 - 1) * a1
	if n <= 0:
		Min = 0
	else:
		n -= (k2 - 1) * a2
		if n <= 0:
			Min = 0
		else:
			Min = min(a1 + a2, n)
	Max = min(a22, nn // k2) + min(a11, (nn - min(a22, nn // k2) * k2) // k1)
else:
	n -= (k2 - 1) * a2
	if n <= 0:
		Min = 0
	else:
		n -= (k1 - 1) * a1
		if n <= 0:
			Min = 0
		else:
			Min = min(a1 + a2, n)
	Max = min(a11, nn // k1) + min(a22, (nn - min(a11, nn // k1) * k1) // k2)
print('{} {}'.format(Min, Max))


import heapq
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
l1 = [-k1 for i in range(a1)]
l2 = [-k2 for i in range(a2)]
l = l1 + l2
lc = l1 + l2
heapq.heapify(lc)
sol = 0
nc = n
while n > 0:
	a = heapq.heappop(lc)
	a += 1
	if a < 0:
		heapq.heappush(lc, a)
	else:
		sol += 1
	n -= 1
l.sort(reverse=True)
sol2 = 0
n = nc
i = 0
while n > 0:
	n += l[i]
	i += 1
	if n >= 0:
		sol2 += 1
print(str(sol) + ' ' + str(sol2))


def main():
	(a1, a2, k1, k2, n) = (int(input()) for _ in range(5))
	if k1 > k2:
		(a1, a2, k1, k2) = (a2, a1, k2, k1)
	i = min(n // k1, a1)
	print(max(n - a1 * (k1 - 1) - a2 * (k2 - 1), 0), i + (n - i * k1) // k2)
main()


a = int(input())
A = int(input())
k = int(input())
K = int(input())
N = int(input())
if k > K:
	(k, K) = (K, k)
	(a, A) = (A, a)
c = (K - 1) * A + (k - 1) * a
res = max(N - c, 0)
X = min(N // k, a)
Y = min(max(N - k * X, 0) // K, A)
RES = X + Y
print(res, RES)


from sys import stdin
import math
a1 = int(stdin.readline())
a2 = int(stdin.readline())
k1 = int(stdin.readline())
k2 = int(stdin.readline())
n = int(stdin.readline())
mn = max(0, n - (a1 * k1 + a2 * k2 - (a1 + a2)))
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
if a1 * k1 <= n:
	mx = a1
	n -= a1 * k1
	mx += n // k2
else:
	mx = n // k1
print(mn, mx)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
s = n - ((k1 - 1) * a1 + (k2 - 1) * a2)
if s < 0:
	s = 0
y = min(k1, k2)
if y == k1:
	(m1, m2, z) = (a1, a2, k2)
else:
	(m1, m2, z) = (a2, a1, k1)
x = min(n // y, m1)
q = min((n - x * y) // z, m2)
print(s, x + q)


a = int(input())
b = int(input())
x = int(input())
y = int(input())
n = int(input())
no = a * (x - 1) + b * (y - 1)
mn = 0
if n > no:
	mn = n - no
d = min(x, y)
e = max(x, y)
mx = 0
p = 0
q = 0
if d == x:
	p = a
	q = b
else:
	p = b
	q = a
if n <= p * d:
	mx = n // d
else:
	mx = (n - p * d) // e
	mx += p
print(mn, mx)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())

def minimum(a1, a2, k1, k2, n):
	k1_temp = k1 - 1
	k2_temp = k2 - 1
	ans = a1 * k1_temp + a2 * k2_temp
	if ans >= n:
		return 0
	diff = n - ans
	if a1 + a2 >= diff:
		return diff
	return a1 + a2

def maximum(a1, a2, k1, k2, n):
	ans = 0
	if k1 < k2:
		if n / k1 >= a1:
			ans = a1
			n = n - ans * k1
			temp = n / k2
			if temp <= a2:
				ans += temp
				return ans
			else:
				return ans + a2
		else:
			return n / k1
	elif n / k2 >= a2:
		ans = a2
		n = n - ans * k2
		temp = n / k1
		if temp <= a1:
			ans += temp
			return ans
		else:
			return ans + a1
	else:
		return n / k2
print(int(minimum(a1, a2, k1, k2, n)), int(maximum(a1, a2, k1, k2, n)))


a = int(input())
b = int(input())
x = int(input())
y = int(input())
n = int(input())
mini = a * (x - 1) + b * (y - 1)
min_ans = max(0, n - mini)
if y < x:
	(a, b) = (b, a)
	(x, y) = (y, x)
max_ans = min(a, n // x)
n = n - max_ans * x
max_ans += min(b, n // y)
print(min_ans, max_ans)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mini = 0
if a1 * (k1 - 1) + a2 * (k2 - 1) < n:
	mini = n - (a1 * (k1 - 1) + a2 * (k2 - 1))
else:
	mini = 0
if k1 < k2:
	if n // k1 > a1:
		card1 = a1
		rem = n - a1 * k1
		card2 = rem // k2
		maxi = card1 + card2
	else:
		maxi = n // k1
elif n // k2 > a2:
	card2 = a2
	rem = n - a2 * k2
	card1 = rem // k1
	maxi = card1 + card2
else:
	maxi = n // k2
print('')
print(mini)
print('')
print(maxi)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mina = 0
maxa = 0
m = n
m = m - (k1 - 1) * a1 - (k2 - 1) * a2
if m < 0:
	mina = 0
else:
	mina = min(m, a1 + a2)
if k1 < k2:
	if n // k1 <= a1:
		maxa = n // k1
	else:
		n = n - k1 * a1
		maxa += a1
		if n // k2 <= a2:
			maxa += n // k2
		else:
			maxa += a2
elif n // k2 <= a2:
	maxa = n // k2
else:
	n = n - k2 * a2
	maxa += a2
	if n // k1 <= a1:
		maxa += n // k1
	else:
		maxa += a1
print(mina, maxa)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = N = int(input())
N -= (k1 - 1) * a1 + (k2 - 1) * a2
if N <= 0:
	print(0, end=' ')
elif N >= a1 + a2:
	print(a1 + a2, end=' ')
else:
	print(N, end=' ')
if k1 >= k2:
	if n / k2 >= a2:
		n -= k2 * a2
		if n / k1 >= a1:
			print(a1 + a2)
		else:
			print(a2 + n // k1)
	else:
		print(n // k2)
elif n / k1 >= a1:
	n -= k1 * a1
	if n / k2 >= a2:
		print(a2 + a1)
	else:
		print(a1 + n // k2)
else:
	print(n // k1)


v = []
for i in range(5):
	v.append(int(input()))
a = v[0]
b = v[1]
x = v[2]
y = v[3]
n = v[4]
p = x * a + y * b
q = p
t = a + b
m = a
z = b
X = x
Y = y
if x > y:
	while p > n:
		if a > 0:
			p += -x
			t += -1
			a += -1
		else:
			p += -y
			t += -1
			b += -1
else:
	while p > n:
		if b > 0:
			p += -y
			t += -1
			b += -1
		else:
			p += -x
			t += -1
			a += -1
p = q
r = 0
a = m
b = z
x = X
y = Y
p = a * (x - 1) + b * (y - 1)
if p > n:
	r = 0
else:
	r = n - p
print(r, t)


a1 = eval(input())
a2 = eval(input())
k1 = eval(input())
k2 = eval(input())
n = eval(input())
a = [a1, k1]
k = [a2, k2]
h = n - ((k1 - 1) * a1 + (k2 - 1) * a2)
print(max(h, 0))
b = min(k1, k2)
m = a2
c = 0
if a[1] == b:
	m = a1
while n >= b and c < m:
	n -= b
	c += 1
ba = max(k1, k2)
ma = a2
if ma == m:
	ma = a1
d = 0
while n >= ba and d < ma:
	n -= ba
	d += 1
print(d + c)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
min = n - (a1 * (k1 - 1) + a2 * (k2 - 1))
if min <= 0:
	min = 0
if k2 < k1:
	n2 = n
	n = n - a2 * k2
	if n <= 0:
		max = n2 // k2
	else:
		n1 = n
		n = n - a1 * k1
		if n <= 0:
			max = n1 // k1 + a2
		else:
			max = a2 + a1
else:
	n1 = n
	n = n - a1 * k1
	if n <= 0:
		max = n1 // k1
	else:
		n2 = n
		n = n - a2 * k2
		if n <= 0:
			max = n2 // k2 + a1
		else:
			max = a2 + a1
print(min, max)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mn = n - ((k1 - 1) * a1 + (k2 - 1) * a2)
if mn < 0:
	mn = 0
elif mn > a1 + a2:
	mn = a1 + a2
t = n
c = 0
if k1 < k2:
	while a1 and t - k1 >= 0:
		t -= k1
		a1 -= 1
		c += 1
	while a2 and t - k2 >= 0:
		t -= k2
		a2 -= 1
		c += 1
else:
	while a2 and t - k2 >= 0:
		t -= k2
		a2 -= 1
		c += 1
	while a1 and t - k1 >= 0:
		t -= k1
		a1 -= 1
		c += 1
print(mn, c)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mn = n
t1 = a1 * (k1 - 1) + a2 * (k2 - 1)
if t1 >= n:
	mn = 0
else:
	t = n - t1
	mn = min(t, a1 + a2)
mx = 0
if k1 < k2:
	t1 = n // k1
	if t1 <= a1:
		mx = t1
	else:
		mx = a1 + (n - a1 * k1) // k2
elif k1 > k2:
	t1 = n // k2
	if t1 <= a2:
		mx = t1
	else:
		mx = a2 + (n - a2 * k2) // k1
else:
	t1 = n // k1
	mx = min(a1 + a2, t1)
print(mn, mx)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
print(max(n - a1 * (k1 - 1) - a2 * (k2 - 1), 0), end=' ')
if k1 > k2:
	(a1, a2) = (a2, a1)
	(k1, k2) = (k2, k1)
send_off_t1 = n // k1
if send_off_t1 <= a1:
	print(send_off_t1)
else:
	print(a1 + (n - a1 * k1) // k2)


def f(l):
	(a1, a2, k1, k2, n) = l
	if k1 > k2:
		(k1, k2, a1, a2) = (k2, k1, a2, a1)
	o1 = min(n // k1, a1)
	o2 = (n - o1 * k1) // k2
	mx = o1 + o2
	mi = max(0, n - k1 * a1 - k2 * a2 + a1 + a2)
	return [mi, mx]
l = [int(input()) for _ in range(5)]
print(*f(l))


from sys import stdin

def ii():
	return int(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def li():
	return list(mi())

def si():
	return stdin.readline()
a = ii()
b = ii()
c = ii()
d = ii()
e = ii()
x = max(0, min(a + b, e - (a * (c - 1) + b * (d - 1))))
if c < d:
	y = min(a, e // c)
	e -= y * c
	y += min(b, e // d)
else:
	y = min(b, e // d)
	e -= y * d
	y += min(a, e // c)
print(x, y)


import sys
I = sys.stdin.readline
a1 = int(I())
a2 = int(I())
k1 = int(I())
k2 = int(I())
n = int(I())
if k1 > k2:
	(k2, k1) = (k1, k2)
	(a1, a2) = (a2, a1)
if a1 * k1 + a2 * k2 <= n:
	print(a1 + a2, a1 + a2)
else:
	max_player = min(a1, n // k1) + min(a2, (n - min(a1, n // k1) * k1) // k2)
	min_player = max(n - a1 * (k1 - 1) - a2 * (k2 - 1), 0)
	print(min_player, max_player)


import sys
(a1, a2, k1, k2, n) = map(int, sys.stdin)
if k1 < k2:
	(a1, a2) = (a2, a1)
	(k1, k2) = (k2, k1)
ans1 = max(0, n - (k1 - 1) * a1 - (k2 - 1) * a2)
ans2 = min(a2, n // k2)
n -= ans2 * k2
if n > 0:
	ans2 += n // k1
print(ans1, ans2)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		a1 = I()
		a2 = I()
		k1 = I()
		k2 = I()
		n = I()
		if k1 > k2:
			(a1, a2) = (a2, a1)
			(k1, k2) = (k2, k1)
		t = max(0, n - ((k1 - 1) * a1 + (k2 - 1) * a2))
		u = min(a1, n // k1)
		n -= k1 * u
		u += min(a2, n // k2)
		rr.append(JA([t, u], ' '))
	return JA(rr, '\n')
print(main())


import sys

def main():
	content = []
	i = 0
	for line in sys.stdin:
		content.append(line)
		i += 1
		if i == 5:
			break
	(a1, a2, k1, k2, n) = (int(content[0]), int(content[1]), int(content[2]), int(content[3]), int(content[4]))
	totalPlayers = 0
	if k1 > k2:
		(a1, a2) = (a2, a1)
		(k1, k2) = (k2, k1)
	k1MaxLimit = int(n / k1)
	if k1MaxLimit >= a1:
		totalPlayers += a1
	else:
		totalPlayers += k1MaxLimit
	n -= totalPlayers * k1
	k2MaxLimit = int(n / k2)
	if k2MaxLimit >= a2:
		totalPlayers += a2
	else:
		totalPlayers += k2MaxLimit
	(a1, a2, k1, k2, n) = (int(content[0]), int(content[1]), int(content[2]), int(content[3]), int(content[4]))
	lowerLimit = a1 * (k1 - 1) + a2 * (k2 - 1)
	lowerLimit = n - lowerLimit
	if lowerLimit < 0:
		lowerLimit = 0
	sys.stdout.write(str(lowerLimit) + ' ' + str(totalPlayers))
main()


a = int(input())
b = int(input())
ya = int(input())
yb = int(input())
y = int(input())
if ya > yb:
	temp = ya
	ya = yb
	yb = temp
	temp = a
	a = b
	b = temp
l = a * (ya - 1) + b * (yb - 1)
mleave = 0
if l < y:
	mleave = y - l
Mleave = 0
if a * ya >= y:
	Mleave = y // ya
else:
	Mleave = a + (y - a * ya) // yb
print(mleave, Mleave)


__author__ = 'Esfandiar'
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
yy = a1 * k1 - a1
yy += a2 * k2 - a2
M1 = max(0, n - yy)
if k1 <= k2:
	res = 0
	for i in range(a1):
		if n - k1 >= 0:
			res += 1
			n -= k1
	for i in range(a2):
		if n - k2 >= 0:
			res += 1
			n -= k2
else:
	res = 0
	for i in range(a2):
		if n - k2 >= 0:
			res += 1
			n -= k2
	for i in range(a1):
		if n - k1 >= 0:
			res += 1
			n -= k1
print(M1, res)


a = int(input())
a1 = int(input())
p = int(input())
p1 = int(input())
n = int(input())
if a * (p - 1) + a1 * (p1 - 1) >= n:
	m = 0
else:
	m = n - (a * (p - 1) + a1 * (p1 - 1))
ma = 0
if p < p1:
	r = p * a
	if r <= n:
		ma += a
		n = n - r
		ma += n // p1
	else:
		ma += n // p
else:
	r = p1 * a1
	if r <= n:
		ma += a1
		n = n - r
		ma += n // p
	else:
		ma += n // p1
print(m, ma)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
h = (k1 - 1) * a1 + (k2 - 1) * a2
print(max(0, n - h), end=' ')
ans = min(n // k1, a1)
n = max(0, n - ans * k1)
ans += n // k2
print(ans)


(a1, a2, k1, k2, n) = (int(input()) for i in range(5))
w1 = a1 * (k1 - 1)
w2 = a2 * (k2 - 1)
n1 = n - w1 - w2
mi = max(0, n1)
if k1 < k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
l2 = n // k2
n2 = min(l2, a2)
n -= n2 * k2
l1 = n // k1
n3 = min(l1, a1)
print(mi, n3 + n2)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if (k1 - 1) * a1 + (k2 - 1) * a2 >= n:
	ans1 = 0
else:
	ans1 = n - ((k1 - 1) * a1 + (k2 - 1) * a2)
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
ans2 = min(a1, n // k1)
ans2 += max(0, min(a2, (n - ans2 * k1) // k2))
print(ans1, ans2)


import math
import sys
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = prime[1] = False
	r = [p for p in range(n + 1) if prime[p]]
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))
a = ii()
b = ii()
ka = ii()
kb = ii()
n = ii()
t = a * (ka - 1)
e = b * (kb - 1)
r = min(max(0, n - e - t), a + b)
if ka > kb:
	t = min(b, n // kb)
	n -= t * kb
	t += min(a, n // ka)
else:
	t = min(a, n // ka)
	n -= t * ka
	t += min(b, n // kb)
print(r, t)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
minDeletedPlayers = 0
maxDeletedPlayers = 0
sum = 0
for i in range(a1):
	sum += k1 - 1
for i in range(a2):
	sum += k2 - 1
if sum - n >= 0:
	minDeletedPlayers = 0
else:
	minDeletedPlayers = n - sum
if k1 <= k2:
	for i in range(a1):
		if n >= k1:
			n -= k1
			maxDeletedPlayers += 1
		else:
			break
	for i in range(a2):
		if n >= k2:
			n -= k2
			maxDeletedPlayers += 1
		else:
			break
else:
	for i in range(a2):
		if n >= k2:
			n -= k2
			maxDeletedPlayers += 1
		else:
			break
	for i in range(a1):
		if n >= k1:
			n -= k1
			maxDeletedPlayers += 1
		else:
			break
print(minDeletedPlayers, maxDeletedPlayers)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
y = int(input())
summ = a1 * (k1 - 1) + a2 * (k2 - 1)
if y > summ:
	mini = y - summ
else:
	mini = 0
maxi = 0
if k1 < k2:
	maxi += y // k1
	if maxi > a1:
		maxi = a1
		y -= k1 * maxi
		maxi += y // k2
	else:
		pass
else:
	maxi += y // k2
	if maxi > a2:
		maxi = a2
		y -= k2 * maxi
		maxi += y // k1
	else:
		pass
print(mini, maxi)


(a1, a2, k1, k2, n) = [int(input()) for _ in range(5)]
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
count = a1 * (k1 - 1) + a2 * (k2 - 1)
x = max(n - count, 0)
y = n // k1 if n <= a1 * k1 else a1 + (n - a1 * k1) // k2
print(x, y)


from sys import stdin, stdout
a1 = int(stdin.readline())
a2 = int(stdin.readline())
k1 = int(stdin.readline())
k2 = int(stdin.readline())
n = int(stdin.readline())
if k1 < k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
mx = 0
mn = 0
n1 = n
r = n1 // k2
mx += min(a2, r)
n1 -= min(a2, r) * k2
r = n1 // k1
mx += min(a1, r)
n1 = n
n1 -= a1 * (k1 - 1) + a2 * (k2 - 1)
if n1 > 0:
	mn = n1
print(f'{mn} {mx}')


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
x1 = a1 * (k1 - 1)
x2 = a2 * (k2 - 1)
if n - x1 - x2 <= 0:
	res_min = 0
else:
	res_min = n - x1 - x2
res_max1 = 0
n1 = n + 0
x1 = int(n1 / k1)
if x1 < a1:
	res_max1 += x1
	n1 -= x1 * k1
else:
	res_max1 += a1
	n1 -= a1 * k1
x2 = int(n1 / k2)
if x2 < a2:
	res_max1 += x2
else:
	res_max1 += a2
res_max2 = 0
n2 = n + 0
x11 = int(n2 / k2)
if x11 < a2:
	res_max2 += x11
	n2 -= x11 * k2
else:
	res_max2 += a2
	n2 -= a2 * k2
x22 = int(n2 / k1)
if x22 < a1:
	res_max2 += x22
else:
	res_max2 += a1
print(str(res_min) + ' ' + str(max(res_max1, res_max2)))


def mini():
	if n - a1 * (k1 - 1) - a2 * (k2 - 1) >= 0:
		return n - a1 * (k1 - 1) - a2 * (k2 - 1)
	else:
		return 0

def maxi():
	if k1 <= k2:
		if n <= a1 * k1:
			return n // k1
		else:
			return a1 + (n - a1 * k1) // k2
	if k1 > k2:
		if n <= a2 * k2:
			return n // k2
		else:
			return a2 + (n - a2 * k2) // k1
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
print(mini(), maxi())


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
k = 10 ** 9
if a1 * (k1 - 1) >= n:
	k = 0
else:
	m = n - a1 * (k1 - 1)
	if a2 * (k2 - 1) > m:
		k = 0
if a2 * (k2 - 1) >= n:
	k = 0
else:
	m = n - a2 * (k2 - 1)
	if a1 * (k1 - 1) > m:
		k = 0
for i in range(a1 + 1):
	for j in range(a2 + 1):
		if i * k1 + j * k2 + (a1 - i) * (k1 - 1) + (a2 - j) * (k2 - 1) == n:
			k = min(i + j, k)
print(k, end=' ')
k_ = 0
for i in range(a1 + 1):
	for j in range(a2 + 1):
		if i * k1 + j * k2 <= n:
			k_ = max(i + j, k_)
print(k_)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
x = a1 * (k1 - 1) + a2 * (k2 - 1)
if n <= x:
	ans1 = 0
else:
	ans1 = n - x
if k1 <= k2:
	if n <= a1 * k1:
		ans2 = n // k1
	else:
		ans2 = a1 + (n - a1 * k1) // k2
elif n <= a2 * k2:
	ans2 = n // k2
else:
	ans2 = a2 + (n - a2 * k2) // k1
print(ans1, ans2)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
m = n
max0 = 0
a = []
for i in range(a1 + a2):
	if i < a1:
		a.append(k1)
	else:
		a.append(k2)
a.sort()
for i in range(a1 + a2):
	if n >= a[i]:
		n -= a[i]
		max0 += 1
for i in range(a1 + a2):
	m -= a[i] - 1
print(max(m, 0), end=' ')
print(max0)


import math as m
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
yellow = int(input())
zellow = yellow * 1
mini = 9000
maxi = 0
if yellow - (k2 * a2 - a2) <= 0:
	mini = 0
else:
	yellow -= k2 * a2 - a2
	if yellow - (k1 * a1 - a1) <= 0:
		mini = 0
	else:
		yellow -= k1 * a1 - a1
		rest = a1 + a2 - yellow
		if rest <= 0:
			mini = a1 + a2
		else:
			mini = a1 + a2 - rest
yellow = zellow
if k1 < k2:
	if yellow > k1 * a1:
		maxi += a1
		yellow -= k1 * a1
		if yellow > k2 * a2:
			maxi += a2
		else:
			rest = k2 * a2 - yellow
			rest = m.ceil(rest / k2)
			maxi += a2 - rest
	else:
		rest = k1 * a1 - yellow
		rest = m.ceil(rest / k1)
		maxi = a1 - rest
elif yellow > k2 * a2:
	maxi += a2
	yellow -= k2 * a2
	if yellow > k1 * a1:
		maxi += a1
	else:
		rest = k1 * a1 - yellow
		rest = m.ceil(rest / k1)
		maxi += a1 - rest
else:
	rest = k2 * a2 - yellow
	rest = m.ceil(rest / k2)
	maxi += a2 - rest
print(mini, maxi)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
l = sorted([[k1, a1], [k2, a2]])
minPlayer = max(0, n - (k1 - 1) * a1 - (k2 - 1) * a2)
maxt1 = min(l[0][1], n // l[0][0])
maxt2 = (n - maxt1 * l[0][0]) // l[1][0]
print(minPlayer, maxt1 + maxt2)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 == 1 and k2 == 1:
	print(n, n)
else:
	netd = a1 * (k1 - 1) + a2 * (k2 - 1) - n
	if netd >= 0:
		mn = 0
	else:
		mn = min(abs(netd), a1 + a2)
	if k1 > k2:
		if a2 * k2 == n:
			mx = a2
		elif a2 * k2 > n:
			mx = n // k2
		else:
			rem = n - a2 * k2
			mx = rem // k1
			mx += a2
	elif a1 * k1 == n:
		mx = a1
	elif a1 * k1 > n:
		mx = n // k1
	else:
		rem = n - a1 * k1
		mx = rem // k2
		mx += a1
	print(mn, mx)


team1 = int(input())
team2 = int(input())
yellow1 = int(input())
yellow2 = int(input())
total = int(input())
temp = team1 * (yellow1 - 1) + team2 * (yellow2 - 1)
max = 0
if total < temp:
	max = 0
elif total - temp >= team1 + team2:
	max = team1 + team2
else:
	max = total - temp
count = 0
if yellow1 < yellow2:
	for x in range(team1):
		if total - yellow1 >= 0:
			total = total - yellow1
			count = count + 1
		else:
			break
	for x in range(team2):
		if total - yellow2 >= 0:
			total = total - yellow2
			count = count + 1
		else:
			break
else:
	for x in range(team2):
		if total - yellow2 >= 0:
			total = total - yellow2
			count = count + 1
		else:
			break
	for x in range(team1):
		if total - yellow1 >= 0:
			total = total - yellow1
			count = count + 1
		else:
			break
print(max, count)


ii = int
(a1, a2, k1, k2, n) = (ii(input()), ii(input()), ii(input()), ii(input()), ii(input()))
if k1 > k2:
	(a1, a2, k1, k2) = (a2, a1, k2, k1)
if n <= a1 * k1:
	big = n // k1
else:
	big = a1 + (n - a1 * k1) // k2
smol = min(a1 + a2, max(0, n - a2 * (k2 - 1) - a1 * (k1 - 1)))
print(smol, big)


a = int(input())
b = int(input())
k1 = int(input())
k2 = int(input())
t = int(input())
t1 = t
min = 0
max = 0
if k1 <= k2:
	no = k1 * a
	ct = 0
	while no > t:
		no = no - k1
		ct = ct + 1
	t = t - no
	max = max + (a - ct) + t // k2
	t = t - t // k2 * k2
else:
	no = k2 * b
	ct = 0
	while no > t:
		no = no - k2
		ct = ct + 1
	t = t - no
	max = max + (b - ct) + t // k1
	t = t - t // k1 * k1
t = t1
if k1 >= k2:
	t = t - (k1 - 1) * a
	if t > 0:
		t = t - (k2 - 1) * b
elif k2 > k1:
	t = t - (k2 - 1) * b
	if t > 0:
		t = t - (k1 - 1) * a
if t < 0:
	t = 0
min = t
print(min, max)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
x = k1
xp = a1
y = k2
yp = a2
if k2 < k1:
	x = k2
	xp = a2
	y = k1
	yp = a1
ymax = a1 + a2
temp = a1 * (k1 - 1) + a2 * (k2 - 1)
if n > temp:
	ymax = ymax - (n - temp)
n1 = a1 + a2 - ymax
n2 = int(n / x)
if n2 > xp:
	n2 = n - x * xp
	n2 = xp + int(n2 / y)
print(n1, n2)


def main():
	a1 = int(input())
	a2 = int(input())
	k1 = int(input())
	k2 = int(input())
	n = int(input())
	n -= a1 * (k1 - 1)
	n -= a2 * (k2 - 1)
	if n <= 0:
		min_val = 0
	else:
		min_val = min(n, a1 + a2)
	n += a1 * (k1 - 1)
	n += a2 * (k2 - 1)
	if k1 <= k2:
		count = 0
		while True:
			n -= k1
			if n >= 0:
				count += 1
			else:
				break
			if count == a1:
				break
		max_val = count
		count = 0
		while True:
			n -= k2
			if n >= 0:
				count += 1
			else:
				break
			if count == a2:
				break
		max_val += count
	else:
		count = 0
		while True:
			n -= k2
			if n >= 0:
				count += 1
			else:
				break
			if count == a2:
				break
		max_val = count
		count = 0
		while True:
			n -= k1
			if n >= 0:
				count += 1
			else:
				break
			if count == a1:
				break
		max_val += count
	print(min_val, max_val)
main()


team_a1 = int(input())
team_a2 = int(input())
yellow_a1 = int(input())
yellow_a2 = int(input())
total_yellow = int(input())
mins = max(0, total_yellow - team_a1 * (yellow_a1 - 1) - team_a2 * (yellow_a2 - 1))
if yellow_a1 > yellow_a2:
	(yellow_a1, yellow_a2) = (yellow_a2, yellow_a1)
	(team_a1, team_a2) = (team_a2, team_a1)
maxs = min(total_yellow // yellow_a1, team_a1)
total_yellow -= maxs * yellow_a1
maxs += min(total_yellow // yellow_a2, team_a2)
print(mins, maxs)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
m = a1 * (k1 - 1) + a2 * (k2 - 1)
t = n
if m >= n:
	min = 0
else:
	n -= m
	min = n
max = 0
if k2 < k1:
	while a2 and t > 0:
		t -= k2
		if t >= 0:
			a2 -= 1
			max += 1
	while a1 and t > 0:
		t -= k1
		if t >= 0:
			a1 -= 1
			max += 1
else:
	while a1 and t > 0:
		t -= k1
		if t >= 0:
			a1 -= 1
			max += 1
	while a2 and t > 0:
		t -= k2
		if t >= 0:
			a2 -= 1
			max += 1
print(str(min) + ' ' + str(max))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
nahune = a1 * (k1 - 1) + a2 * (k2 - 1)
if n <= nahune:
	kam = 0
else:
	kam = n - nahune
x = min(k1, k2)
y = min(a1, a2)
badhi = 0
if k2 < k1:
	no = n // k2
	if no <= a2:
		badhi += no
	else:
		badhi += a2
		n = n - a2 * k2
		no = n // k1
		badhi += no
else:
	no = n // k1
	if no <= a1:
		badhi += no
	else:
		badhi += a1
		n = n - a1 * k1
		no = n // k2
		badhi += no
print(kam, badhi)


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

def getVars():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def getStr():
	return input().strip()

def addDictList(d, key, val):
	if key not in d:
		d[key] = []
	d[key].append(val)

def addDictInt(d, key, val):
	if key not in d:
		d[key] = 0
	d[key] = val

def addDictCount(d, key):
	if key not in d:
		d[key] = 0
	d[key] += 1

def addDictSum(d, key, val):
	if key not in d:
		d[key] = 0
	d[key] += val
a1 = getInt()
a2 = getInt()
k1 = getInt()
k2 = getInt()
n = getInt()
resmin = max(0, n - (k1 - 1) * a1 - (k2 - 1) * a2)
if k1 > k2:
	(k1, k2, a1, a2) = (k2, k1, a2, a1)
resmax = min(a1, n // k1)
n -= resmax * k1
resmax += n // k2
print(resmin, resmax)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
(l, h) = (0, 0)
x = [(k1, a1), (k2, a2)]
x.sort()
m = n
for i in range(2):
	z = min(x[i][1], m // x[i][0])
	h += z
	m -= z * x[i][0]
l = max(n - a1 * (k1 - 1) - a2 * (k2 - 1), 0)
print(l, h)


(a1, a2, k1, k2) = (int(input()), int(input()), int(input()), int(input()))
n1 = int(input())
n2 = n1
if k1 < k2:
	res = min(n1 // k1, a1)
	n1 -= res * k1
	res += n1 // k2
else:
	res = min(n1 // k2, a2)
	n1 -= res * k2
	res += n1 // k1
(mn, mx) = (0, 0)
n2 = max(0, n2 - (k2 - 1) * a2 - (k1 - 1) * a1)
print(n2, res)


def run():
	a1 = eval(input())
	a2 = eval(input())
	k1 = eval(input())
	k2 = eval(input())
	n = eval(input())
	mx_k = max(k1, k2)
	mn_k = min(k1, k2)
	if k1 == mx_k:
		mn_a = a2
		mx_a = a1
	else:
		mn_a = a1
		mx_a = a2
	c1 = min(mn_a, n // mn_k)
	remain_n = n - c1 * mn_k
	if remain_n >= 0:
		c1 += min(mx_a, remain_n // mx_k)
	c1 = min(c1, a1 + a2)
	if mx_k > 1:
		c2 = n // (mx_k - 1)
		if c2 >= mx_a:
			c2 = mx_a
		else:
			c2 = 0
			print(c2, c1)
			return
	else:
		c2 = 0
	remain_n = n - c2 * (mx_k - 1)
	if remain_n >= 0 and mn_k > 1:
		c2_2 = remain_n // (mn_k - 1)
		if c2_2 >= mn_a:
			c2_2 = mn_a
		else:
			c2_2 = 0
			c2 = 0
			print(c2, c1)
			return
	else:
		c2_2 = 0
	c2 = n - c2 * (mx_k - 1) - c2_2 * (mn_k - 1)
	if c2 < 0:
		c2 = 0
	c2 = min(c2, a1 + a2)
	print(c2, c1)
run()


import math
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if n == a1 * k1 + a2 * k2:
	print(a1 + a2)
	print(a1 + a2)
else:
	if k2 > k1:
		(temp1, temp2) = (a1, k1)
		(a1, k1) = (a2, k2)
		(a2, k2) = (temp1, temp2)
	min0 = a1 * (k1 - 1) + a2 * (k2 - 1)
	if n > min0:
		print(n - min0)
	else:
		print(0)
	count = 0
	if n > k2 * a2:
		count += a2
		n -= k2 * a2
		p = math.floor(n / k1)
		count += p
		print(count)
	else:
		p = math.floor(n / k2)
		print(int(p))


def footballMatch():
	a1 = int(input())
	a2 = int(input())
	k1 = int(input())
	k2 = int(input())
	n = int(input())
	if k1 > k2:
		maxPlayerFrom2 = min(n // k2, a2)
		maxPlayerFrom1 = (n - maxPlayerFrom2 * k2) // k1
		maxPlayer = maxPlayerFrom2 + maxPlayerFrom1
		minPlayer1 = n - (k1 - 1) * a1
		minPlayer = 0
		if minPlayer1 <= 0:
			minPlayer = 0
		else:
			minPlayer2 = minPlayer1 - (k2 - 1) * a2
			if minPlayer2 <= 0:
				minPlayer = 0
			else:
				minPlayer = minPlayer2
		print(str(minPlayer) + ' ' + str(maxPlayer))
	else:
		maxPlayerFrom1 = min(n // k1, a1)
		maxPlayerFrom2 = (n - maxPlayerFrom1 * k1) // k2
		maxPlayer = maxPlayerFrom1 + maxPlayerFrom2
		minPlayer2 = n - (k2 - 1) * a2
		minPlayer = 0
		if minPlayer2 <= 0:
			minPlayer = 0
		else:
			minPlayer1 = minPlayer2 - (k1 - 1) * a1
			if minPlayer1 <= 0:
				minPlayer = 0
			else:
				minPlayer = minPlayer1
		print(str(minPlayer) + ' ' + str(maxPlayer))
footballMatch()


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
Thresh = (k1 - 1) * a1 + (k2 - 1) * a2
if Thresh >= n:
	min = 0
else:
	min = n - Thresh
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
if a1 * k1 >= n:
	max = n // k1
else:
	max = a1
	n -= a1 * k1
	max += n // k2
print(min, max)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
temp = n
temp -= (k1 - 1) * a1
temp -= (k2 - 1) * a2
if temp > 0:
	mi = temp
else:
	mi = 0
if k1 < k2:
	mx = min(n // k1, a1)
	n -= mx * k1
	if n >= k2:
		mx += min(n // k2, a2)
else:
	mx = min(n // k2, a2)
	n -= mx * k2
	if n >= k2:
		mx += min(n // k1, a1)
print(mi, mx)


(a1, a2, k1, k2, n) = (int(input()), int(input()), int(input()), int(input()), int(input()))
if k1 < k2:
	r = min(a1, n // k1)
	m = n
	s = a1 * (k1 - 1) + a2 * (k2 - 1)
	n -= r * k1
	print(max(0, m - s), r + n // k2)
else:
	r = min(a2, n // k2)
	m = n
	s = a1 * (k1 - 1) + a2 * (k2 - 1)
	n -= r * k2
	print(max(0, m - s), r + n // k1)


import os
import sys
from math import *
from collections import *
from heapq import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
a1 = Int()
a2 = Int()
k1 = Int()
k2 = Int()
n = Int()
MIN = inf
MAX = -1
if k1 < k2:
	temp = min(a1, n // k1)
	rem_n = n - k1 * temp
	temp += min(a2, rem_n // k2)
	MAX = max(temp, MAX)
else:
	temp = min(a2, n // k2)
	rem_n = n - k2 * temp
	temp += min(a1, rem_n // k1)
	MAX = max(temp, MAX)
n -= a1 * (k1 - 1)
n -= a2 * (k2 - 1)
if n < 0:
	n = 0
MIN = min(n, a1 + a2)
print(MIN, MAX)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())

def get_min(a1, a2, k1, k2, n):
	n -= a1 * (k1 - 1)
	n -= a2 * (k2 - 1)
	if n > 0:
		return n
	else:
		return 0

def get_max(a1, a2, k1, k2, n):
	m = 0
	if k1 < k2:
		while a1 > 0 and n >= k1:
			n -= k1
			a1 -= 1
			m += 1
		while a2 > 0 and n >= k2:
			n -= k2
			a2 -= 1
			m += 1
	else:
		while a2 > 0 and n >= k2:
			n -= k2
			a2 -= 1
			m += 1
		while a1 > 0 and n >= k1:
			n -= k1
			a1 -= 1
			m += 1
	return m
print(get_min(a1, a2, k1, k2, n), get_max(a1, a2, k1, k2, n))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
n2 = n
not_kicked = a1 * (k1 - 1) + a2 * (k2 - 1)
n2 = n - not_kicked
ans_min = max(0, n2)
ans1 = 0
ans1 += min(a1, n // k1)
n2 = n - k1 * ans1
ans1 += min(a2, n2 // k2)
ans2 = 0
ans2 += min(a2, n // k2)
n2 = n - k2 * ans2
ans2 += min(a1, n2 // k1)
ans_max = max(ans1, ans2)
print(ans_min, ans_max)


def inp():
	return int(input())
a1 = inp()
a2 = inp()
k1 = inp()
k2 = inp()
n = inp()
if k1 > k2:
	(a1, a2) = (a2, a1)
	(k1, k2) = (k2, k1)
a1so = min(a1, n // k1)
a2so = min(a2, (n - a1so * k1) // k2)
mx = a1so + a2so
totp = a1 * (k1 - 1) + a2 * (k2 - 1)
print(max(0, n - totp), mx)


a = int(input())
b = int(input())
k1 = int(input())
k2 = int(input())
n = m = int(input())
k3 = (k1 - 1) * a
k4 = (k2 - 1) * b
k5 = k3 + k4
if n >= k5:
	print(n - k5, end=' ')
else:
	print(0, end=' ')
s = 0
c = min(k1, k2)
if c == k1:
	while a > 0:
		if n < k1:
			break
		n = n - k1
		s += 1
		a -= 1
	if n > 0:
		while b > 0:
			if n < k2:
				break
			n -= k2
			s += 1
			b -= 1
elif c == k2:
	while b > 0:
		if n < k2:
			break
		n = n - k2
		s += 1
		b -= 1
	if n > 0:
		while a > 0:
			if n < k1:
				break
			n -= k1
			s += 1
			a -= 1
print(s)


from copy import deepcopy
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
cards_left = int(input())
cards_left2 = deepcopy(cards_left)
lesser = (0, 1)[k2 < k1]
data = [(a1, k1), (a2, k2)]
weaker = data[lesser]
stronger = data[not lesser]
cardstack = [weaker[1] for _ in range(weaker[0])] + [stronger[1] for _ in range(stronger[0])]
kicked_max = 0
i = 0
while cards_left != 0:
	current = cardstack[i]
	if cards_left < current:
		break
	cards_left -= current
	kicked_max += 1
	i += 1
kicked_max
g = lambda x: x if x > 0 else 0
supplementary = [x - 1 for x in cardstack if x - 1 > 0]
kicked_min = g(cards_left2 - sum(supplementary))
print(kicked_min, kicked_max)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 == k2:
	total_players = a1 + a2
	left = total_players * (k1 - 1)
	if left >= n:
		minimum = 0
	else:
		left = n - left
		if left <= total_players:
			minimum = left
		else:
			minimum = total_players
	maximum = n // k1
	if maximum >= total_players:
		maximum = total_players
	print(minimum, maximum)
elif k1 < k2:
	left = (k1 - 1) * a1 + (k2 - 1) * a2
	left = n - left
	if left <= 0:
		minimum = 0
	elif left <= a1 + a2:
		minimum = left
	else:
		minimum = a1 + a2
	left = k1 * a1
	if left >= n:
		maximum = n // k1
	else:
		left = n - left
		maximum = a1
		maximum += left // k2
	print(minimum, maximum)
else:
	left = (k1 - 1) * a1 + (k2 - 1) * a2
	left = n - left
	if left <= 0:
		minimum = 0
	elif left <= a1 + a2:
		minimum = left
	else:
		minimum = a1 + a2
	left = k2 * a2
	if left >= n:
		maximum = n // k2
	else:
		left = n - left
		maximum = a2
		maximum += left // k1
	print(minimum, maximum)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
k = int(input())
if a1 * (k1 - 1) + a2 * (k2 - 1) > k:
	answer1 = 0
else:
	answer1 = k - (a1 * (k1 - 1) + a2 * (k2 - 1))
answer2 = 0
if k1 < k2:
	answer2 = min(k // k1, a1)
	k = k - answer2 * k1
	if k >= k2:
		answer2 += min(k // k2, a2)
else:
	answer2 = min(k // k2, a2)
	k = k - answer2 * k2
	if k >= k1:
		answer2 += min(k // k1, a1)
print(answer1, answer2)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
yellow_cards = int(input())
minimum_nb = None
yellow_cards_bis = yellow_cards
i = 0
while i < k1 - 1:
	yellow_cards_bis -= a1
	i += 1
j = 0
while j < k2 - 1:
	yellow_cards_bis -= a2
	j += 1
if yellow_cards_bis < 0:
	minimum_nb = 0
else:
	total_nb = a1 + a2
	minimum_nb = max(yellow_cards_bis, 0)

def compute_max(a1, a2, k1, k2, yellow_cards):
	yellow_cards_for_max = yellow_cards
	hypothetical_maximum_nb_removed_team1 = yellow_cards_for_max // k1
	if hypothetical_maximum_nb_removed_team1 <= a1:
		maximum_nb = hypothetical_maximum_nb_removed_team1
	else:
		remaining_yellow_cards = (hypothetical_maximum_nb_removed_team1 - a1) * k1 + yellow_cards_for_max % k1
		hypothethical_maximum_nb_removed_team2 = remaining_yellow_cards // k2
		if hypothethical_maximum_nb_removed_team2 <= a2:
			maximum_nb = hypothethical_maximum_nb_removed_team2 + a1
		else:
			maximum_nb = a1 + a2
	return maximum_nb
max_nb = None
if k1 < k2:
	max_nb = compute_max(a1, a2, k1, k2, yellow_cards)
else:
	max_nb = compute_max(a2, a1, k2, k1, yellow_cards)
print(str(minimum_nb) + ' ' + str(max_nb))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
ud1 = 0
ud2 = 0
cnt = a1 * (k1 - 1) + a2 * (k2 - 1)
if cnt >= 0:
	c = max(n - cnt, 0)
else:
	c = 0
if k1 < k2:
	ud1 = min(n // k1, a1)
	n -= ud1 * k1
	ud2 = min(n // k2, a2)
else:
	ud1 = min(n // k2, a2)
	n -= ud1 * k2
	ud2 = min(n // k1, a1)
print(c, ud1 + ud2)


def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
import math
a1 = ii()
a2 = ii()
k1 = ii()
k2 = ii()
n = ii()
c = a1 * k1 + a2 * k2 - (a1 + a2)
if n <= c:
	mn = 0
else:
	mn = n - c
if k1 < k2:
	if n <= k1 * a1:
		mx = n // k1
	else:
		mx = a1
		n -= k1 * a1
		mx += n // k2
elif n <= k2 * a2:
	mx = n // k2
else:
	mx = a2
	n -= k2 * a2
	mx += n // k1
print(mn, mx)


a = int(input())
b = int(input())
k = int(input())
l = int(input())
n = int(input())
mi = 0
ma = 0
if (k - 1) * a + (l - 1) * b >= n:
	mi = 0
else:
	mi = n - (k - 1) * a - (l - 1) * b
if k > l:
	if n // l > b:
		ma += b + (n - b * l) // k
	else:
		ma += n // l + (n - n // l * l) // k
elif n // k > a:
	ma += a + (n - a * k) // l
else:
	ma += n // k + (n - n // k * k) // l
mi = min(a + b, mi)
ma = min(a + b, ma)
print(mi, ma)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mx = 0
e = a1 * (k1 - 1) + a2 * (k2 - 1)
if n - e <= 0:
	mn = 0
else:
	mn = n - e
if k1 < k2:
	if a1 < n // k1:
		mx = a1 + (n - a1 * k1) // k2
	else:
		mx = n // k1
elif a2 < n // k2:
	mx = a2 + (n - a2 * k2) // k1
else:
	mx = n // k2
print(mn, mx)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
n = int(input())
save = n
count = 0
if c > d:
	while True:
		n = n - d
		if n < 0:
			break
		count = count + 1
		if count >= b:
			break
	if n <= 0:
		ma = count
	else:
		count = 0
		while True:
			n = n - c
			if n < 0:
				break
			count = count + 1
			if count >= a:
				break
		if n < 0:
			ma = b + count
		else:
			ma = a + b
else:
	count = 0
	while True:
		n = n - c
		if n < 0:
			break
		count = count + 1
		if count >= a:
			break
	if n < 0:
		ma = count
	else:
		count = 0
		while True:
			n = n - d
			if n < 0:
				break
			count = count + 1
			if count >= b:
				break
		if n < 0:
			ma = a + count
		else:
			ma = a + b
n = save
threshold = (c - 1) * a + (d - 1) * b
if n <= threshold:
	mi = 0
else:
	n = n - threshold
	if n >= a + b:
		mi = a + b
	else:
		mi = n
print(mi, ma)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
r = a1 * (k1 - 1) + a2 * (k2 - 1)
if r >= n:
	low = 0
else:
	low = n - r
if k1 < k2:
	high = min(a1, n // k1)
	n -= high * k1
	if n > 0:
		high += min(a2, n // k2)
else:
	high = min(a2, n // k2)
	n -= high * k2
	if n > 0:
		high += min(a1, n // k1)
print(low, high)


(a1, a2, k1, k2, n) = (int(input()) for _ in range(5))
if k1 > k2:
	(k1, a1, k2, a2) = (k2, a2, k1, a1)
t = a1 * (k1 - 1) + a2 * (k2 - 1)
minReds = max(0, n - t)
maxReds1 = min(a1, n // k1)
n -= maxReds1 * k1
maxReds2 = min(a2, n // k2)
print(minReds, maxReds1 + maxReds2)


I = lambda : int(input())
(a1, a2, k1, k2, n) = (I(), I(), I(), I(), I())
if k1 > k2:
	(a1, k1, a2, k2) = (a2, k2, a1, k1)
x = min(a1, n // k1)
y = min(a2, (n - x * k1) // k2)
print(max(0, n - a1 * (k1 - 1) - a2 * (k2 - 1)), x + y)


def Sort(sub_li):
	return sorted(sub_li, key=lambda x: x[1])
n1 = int(input())
n2 = int(input())
p = int(input())
o = int(input())
y = int(input())
L = []
D = []
D.append(n1)
D.append(p)
L.append(D)
D = []
D.append(n2)
D.append(o)
L.append(D)
Q = Sort(L)
Q.reverse()
ans = y
G = 0
tot = 0
for i in range(0, len(Q)):
	A = (Q[i][1] - 1) * Q[i][0]
	tot += A
	if tot >= ans:
		G = 1
		break
if G == 1:
	print(0, end=' ')
else:
	ans -= tot
	tot = A
	G = 0
	for i in range(0, len(Q)):
		A = Q[i][0]
		tot += A
		if tot >= ans:
			tot = ans
			G = 1
			break
	if G == 1:
		print(tot, end=' ')
	else:
		print(ans, end=' ')
Q.reverse()
ans = y
G = 0
tot = 0
K = 0
for i in range(0, len(Q)):
	A = Q[i][1] * Q[i][0]
	if A <= ans:
		ans -= A
		tot += Q[i][0]
	else:
		tot += ans // Q[i][1]
		break
print(tot)


first = int(input())
second = int(input())
a = int(input())
b = int(input())
n = int(input())
maxim = minim = 0
m = first * (a - 1) + second * (b - 1)
if m < n:
	minim += n - m
if a >= b:
	(a, b) = (b, a)
	(first, second) = (second, first)
r = a * first
if r >= n:
	maxim = maxim + n // a
else:
	n = n - r
	maxim = maxim + first
	maxim = maxim + n // b
print(minim, maxim)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
minc = 0
maxc = 0
if k1 > k2:
	if int(n / k2) >= a2:
		maxc += a2
	else:
		maxc += int(n / k2)
	n1 = n - maxc * k2
	if int(n1 / k1) >= a1:
		maxc += a1
	else:
		maxc += int(n1 / k1)
	if n - (a1 * (k1 - 1) + a2 * (k2 - 1)) <= 0:
		minc = 0
	else:
		n1 = n - a1 * (k1 - 1) - a2 * (k2 - 1)
		if n1 <= a1 + a2:
			minc += n1
		else:
			minc = minc + a1 + a2
else:
	if int(n / k1) >= a1:
		maxc += a1
	else:
		maxc += int(n / k1)
	n1 = n - maxc * k1
	if int(n1 / k2) >= a2:
		maxc += a2
	else:
		maxc += int(n1 / k2)
	if n - (a1 * (k1 - 1) + a2 * (k2 - 1)) <= 0:
		minc = 0
	else:
		n1 = n - a1 * (k1 - 1) - a2 * (k2 - 1)
		if n1 <= a1 + a2:
			minc += n1
		else:
			minc = minc + a1 + a2
print(minc, maxc)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
t = int(input())
x1 = min(a1, t // k1)
x2 = min(a2, (t - x1 * k1) // k2)
mx1 = x1 + x2
y1 = min(a2, t // k2)
y2 = min(a1, (t - y1 * k2) // k1)
mx2 = y1 + y2
s = a1 * (k1 - 1) + a2 * (k2 - 1)
mn = max(0, t - s)
print(mn, max(mx1, mx2))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n1 = int(input())
n2 = n1
if a1 * k1 + a2 * k2 == n1:
	print(a1 + a2, end=' ')
	print(a1 + a2)
	exit(0)
minimum = 0
d = n1 - (k1 - 1) * a1 - (k2 - 1) * a2
if d > 0:
	minimum = d
print(minimum, end=' ')
maximum = 0
if k1 < k2:
	d = int(n2 / k1)
	if d > a1:
		d = a1
	n2 = n2 - d * k1
	maximum += d
	d = int(n2 / k2)
	if d > a2:
		d = a2
	n2 = n2 - d * k2
	maximum += d
else:
	d = int(n2 / k2)
	if d > a2:
		d = a2
	n2 = n2 - d * k2
	maximum += d
	d = int(n2 / k1)
	if d > a1:
		d = a1
	n2 = n2 - d * k1
	maximum += d
print(maximum)


R = lambda : map(int, input().split())
K = lambda : int(input())
n1 = K()
n2 = K()
k1 = K()
k2 = K()
n = K()
s = n1 * (k1 - 1) + n2 * (k2 - 1)
if s >= n:
	print(0, end=' ')
else:
	print(min(n1 + n2, n - s), end=' ')
ma = 0
if k1 > k2:
	for i in range(n2):
		if n >= k2:
			n -= k2
			ma += 1
		else:
			break
	for i in range(n1):
		if n >= k1:
			n -= k1
			ma += 1
		else:
			break
	print(ma)
else:
	for i in range(n1):
		if n >= k1:
			n -= k1
			ma += 1
		else:
			break
	for i in range(n2):
		if n >= k2:
			n -= k2
			ma += 1
		else:
			break
	print(ma)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 < k2:
	aux = (k1, a1)
	(k1, a1) = (k2, a2)
	(k2, a2) = aux
z = a1 * (k1 - 1) + a2 * (k2 - 1)
if z >= n:
	mini = 0
else:
	mini = n - z
z = k2 * a2
if z >= n:
	maxi = int(n / k2)
else:
	maxi = a2 + int((n - z) / k1)
print(mini, maxi)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
max1 = a1 * k1 + a2 * k2
min1 = a1 * (k1 - 1) + a2 * (k2 - 1)

def maxn(m):
	if k1 >= k2:
		kb = k1
		kl = k2
		ab = a1
		al = a2
	else:
		kb = k2
		kl = k1
		ab = a2
		al = a1
	if m <= al * kl:
		maxn = m // kl
	else:
		maxn = al + (m - kl * al) // kb
	return maxn

def minn(m):
	if k1 >= k2:
		kb = k1
		kl = k2
		ab = a1
		al = a2
	else:
		kb = k2
		kl = k1
		ab = a2
		al = a1
	if m <= min1:
		minn = 0
	else:
		minn = m - min1
	return minn
print(minn(n), maxn(n))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
ans1 = 0
ans2 = 0
for i in range(0, a1 + 1):
	for j in range(0, a2 + 1):
		if i * k1 + j * k2 <= n:
			ans1 = max(ans1, i + j)
ans2 = a1 * (k1 - 1) + a2 * (k2 - 1)
if n >= ans2:
	print(min(n - ans2, a1 + a2), ans1)
else:
	print(0, ans1)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())

def max_min(k1, k2, a1, a2, n, minout):
	if k1 * a1 <= n:
		temp = 0
		temp = n - k1 * a1
		if temp % k2 == 0:
			max_n = a1 + temp / k2
			print(minout, '', int(max_n))
		if temp % k2 != 0:
			max_n = a1 + int(temp / k2)
			print(minout, '', int(max_n))
	elif k1 * a1 > n:
		max_n = int(n / k1)
		print(minout, '', int(max_n))
minout = n - (a1 * (k1 - 1) + a2 * (k2 - 1))
if minout <= 0:
	minout = 0
if k1 == k2:
	if k1 * a1 <= n:
		temp = 0
		temp = n - k1 * a1
		if temp % k2 == 0:
			max_n = a1 + temp / k2
			print(minout, '', int(max_n))
		if temp % k2 != 0:
			max_n = a1 + int(temp / k2)
			print(minout, '', int(max_n))
	else:
		max_n = int(n / k1)
		print(minout, '', int(max_n))
if k1 < k2:
	max_min(k1, k2, a1, a2, n, minout)
if k1 > k2:
	temp = k2
	k2 = k1
	k1 = temp
	temp1 = 0
	a1 = temp1
	a1 = a2
	a2 = temp1
	max_min(k1, k2, a1, a2, n, minout)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
n1 = n
if k1 < k2:
	if k1 * a1 >= n:
		b = n // k1
	else:
		n -= k1 * a1
		if n >= k2 * a2:
			b = a1 + a2
		else:
			t = n // k2
			b = a1 + t
elif k2 * a2 >= n:
	b = n // k2
else:
	n -= k2 * a2
	if n >= k1 * a1:
		b = a1 + a2
	else:
		t = n // k1
		b = a2 + t
n1 -= (k1 - 1) * a1
n1 -= (k2 - 1) * a2
if n1 <= 0:
	a = 0
elif n1 < a1 + a2:
	a = n1
else:
	a = a1 + a2
print(a, b)


for _ in range(1):
	a1 = int(input())
	a2 = int(input())
	k1 = int(input())
	k2 = int(input())
	n = int(input())
	n1 = n
	m1 = 0
	if k1 <= k2:
		for i in range(1, a1 + 1):
			if k1 <= n1:
				m1 += 1
				n1 -= k1
		for i in range(1, a2 + 1):
			if k2 <= n1:
				m1 += 1
				n1 -= k2
	else:
		for i in range(1, a2 + 1):
			if k2 <= n1:
				m1 += 1
				n1 -= k2
		for i in range(1, a1 + 1):
			if k1 <= n1:
				m1 += 1
				n1 -= k1
	n1 = n
	minc = 0
	v1 = a1 * (k1 - 1)
	v2 = a2 * (k2 - 1)
	if v1 + v2 >= n1:
		minc = 0
	else:
		minc = n1 - (v1 + v2)
	print(minc, m1)


(a1, a2, k1, k2, n) = (int(input()), int(input()), int(input()), int(input()), int(input()))
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
oleg = a1 * (k1 - 1) + a2 * (k2 - 1)
rm = max(0, n - oleg)
if n <= a1 * k1:
	rp = n // k1
else:
	rp = a1
	rp += (n - a1 * k1) // k2
print(rm, rp)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
ma = -1
for i in range(a1 + 1):
	for j in range(a2 + 1):
		if k1 * i + k2 * j <= n:
			ma = max(ma, i + j)
n -= (k1 - 1) * a1 + (k2 - 1) * a2
print(max(n, 0), ma)


x1 = int(input())
x2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 > k2:
	x = x1
	x1 = x2
	x2 = x
	k = k1
	k1 = k2
	k2 = k
mi = max(n - (k1 - 1) * x1 - (k2 - 1) * x2, 0)
ma = min(n // k1, x1) + max(n - min(n // k1, x1) * k1, 0) // k2
print(mi, ma)


from sys import setcheckinterval, stdin, setrecursionlimit
setcheckinterval(1000)
setrecursionlimit(10 ** 7)

def iin():
	return int(stdin.readline())

def lin():
	return list(map(int, stdin.readline().split()))
(a1, a2, k1, k2, n) = (iin(), iin(), iin(), iin(), iin())
nn = n
if k1 < k2:
	(a1, a2) = (a2, a1)
	(k1, k2) = (k2, k1)
sol = [0, 0]
sol[0] = max(0, n - (k1 * a1 - a1 + k2 * a2 - a2))
if k2 * a2 >= nn:
	sol[1] += nn // k2
else:
	sol[1] += a2
	nn -= a2 * k2
	sol[1] += nn // k1
print(*sol)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
nmn = n = int(input())
players = [k1 for _ in range(a1)] + [k2 for _ in range(a2)]
mx = 0
mxcount = 0
mn = 0
for i in range(a1 + a2):
	while players[i] > 1:
		players[i] -= 1
		nmn -= 1
i = 0
while nmn > 0 and players.count(0) != a1 + a2:
	if players[i] == 1:
		players[i] = 0
		nmn -= 1
		mn += 1
	i += 1
if min(k1, k2) == k1:
	while a1 > 0 and mxcount + k1 <= n:
		mxcount += k1
		mx += 1
		a1 -= 1
	while a2 > 0 and mxcount + k2 <= n:
		mxcount += k2
		mx += 1
		a2 -= 1
else:
	while a2 > 0 and mxcount + k2 <= n:
		mxcount += k2
		mx += 1
		a2 -= 1
	while a1 > 0 and mxcount + k1 <= n:
		mxcount += k1
		mx += 1
		a1 -= 1
print(mn, mx)


exec('a,b,c,d,n=' + 'int(input()),' * 5)
if d < c:
	(a, b, c, d) = (b, a, d, c)
print(max(0, n - a * (c - 1) - b * (d - 1)), [n // c, a + (n - a * c) // d][n > a * c])


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 < k2:
	(kmin, amin) = (k1, a1)
	(kmax, amax) = (k2, a2)
else:
	(kmin, amin) = (k2, a2)
	(kmax, amax) = (k1, a1)
nmax = n
cardmax = 0
while amin > 0:
	nmax -= kmin
	amin -= 1
	if nmax >= 0:
		cardmax += 1
	else:
		break
while amax > 0:
	nmax -= kmax
	amax -= 1
	if nmax >= 0:
		cardmax += 1
	else:
		break
nmin = n - (k1 - 1) * a1 - (k2 - 1) * a2
cardmin = max(nmin, 0)
print(cardmin, cardmax)


def max(n, m):
	if n >= m:
		return n
	return m

def min(n, m):
	if n >= m:
		return m
	return n
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
min = 0
x = a1 * (k1 - 1) + a2 * (k2 - 1)
if n >= x:
	min = n - x
	if min > a1 + a2:
		min = a1 + a2
elif n < x:
	min = 0
if k1 <= k2:
	y = a1 * k1
	counter = 0
	while n >= k1 and y != 0:
		n -= k1
		y -= k1
		counter += 1
	y = a2 * k2
	while n >= k2 and y != 0:
		n -= k2
		y -= k2
		counter += 1
elif k1 >= k2:
	y = a2 * k2
	counter = 0
	while n >= k2 and y != 0:
		n -= k2
		y -= k2
		counter += 1
	y = a1 * k1
	while n >= k1 and y != 0:
		n -= k1
		y -= k1
		counter += 1
max = counter
print(min, max)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
e = n
cmin = 0
cmax = 0
if k1 >= k2:
	r1 = a1 * k1
	r2 = a1 * k1 - a1
	r01 = r1 - r2
	r3 = a2 * k2
	r4 = a2 * k2 - a2
	r11 = r3 - r4
	n = n - r2
	if n <= 0:
		cmin = 0
	else:
		n = n - r4
		if n <= 0:
			cmin = 0
		elif n >= r01 + r11:
			cmin = a1 + a2
		else:
			for i in range(1, r01 + r11 + 1):
				if n - i <= 0:
					cmin = i
					break
	n = e
	r1 = a1 * k1
	r2 = a2 * k2
	re = n // k2
	if re == 0:
		cmax = 0
	elif re >= a2:
		cmax = cmax + a2
		n = n - r2
		if n == 0:
			pass
		else:
			re1 = n // k1
			if re1 == 0:
				pass
			elif re1 >= a1:
				cmax = cmax + a1
			else:
				cmax = cmax + re1
	else:
		cmax = cmax + re
else:
	r1 = a1 * k1
	r2 = a1 * k1 - a1
	r01 = r1 - r2
	r3 = a2 * k2
	r4 = a2 * k2 - a2
	r11 = r3 - r4
	n = n - r4
	if n <= 0:
		cmin = 0
	else:
		n = n - r2
		if n <= 0:
			cmin = 0
		elif n >= r01 + r11:
			cmin = a1 + a2
		else:
			for i in range(1, r01 + r11 + 1):
				if n - i <= 0:
					cmin = i
					break
	n = e
	r1 = a1 * k1
	r2 = a2 * k2
	re = n // k1
	if re == 0:
		cmax = 0
	elif re >= a1:
		cmax = cmax + a1
		n = n - r1
		if n == 0:
			pass
		else:
			re1 = n // k2
			if re1 == 0:
				pass
			elif re1 >= a2:
				cmax = cmax + a2
			else:
				cmax = cmax + re1
	else:
		cmax = cmax + re
print(cmin, cmax)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
n1 = n
flag = 0
minn = 0
maxx = 0
if n1 >= k1 or n1 >= k2:
	if k1 >= k2:
		for i in range(a1):
			if n1 - (k1 - 1) >= 0:
				n1 = n1 - (k1 - 1)
			else:
				flag = 1
				break
		if flag == 1:
			minn = 0
		else:
			for i in range(a2):
				if n1 - (k2 - 1) >= 0:
					n1 = n1 - (k2 - 1)
				else:
					flag = 1
					break
			if flag == 1:
				minn = 0
			else:
				minn = n1
	else:
		n1 = n
		flag = 0
		for i in range(a2):
			if n1 - (k2 - 1) >= 0:
				n1 = n1 - (k2 - 1)
			else:
				flag = 1
				break
		if flag == 1:
			minn = 0
		else:
			for i in range(a1):
				if n1 - (k1 - 1) >= 0:
					n1 = n1 - (k1 - 1)
				else:
					flag = 1
					break
			if flag == 1:
				minn = 0
			else:
				minn = n1
else:
	minn = 0
temp = 0
if k1 <= k2:
	n1 = n
	for i in range(a1):
		if n1 - k1 >= 0:
			n1 = n1 - k1
			temp += 1
	for i in range(a2):
		if n1 - k2 >= 0:
			n1 = n1 - k2
			temp += 1
	maxx = temp
else:
	n1 = n
	for i in range(a2):
		if n1 - k2 >= 0:
			n1 = n1 - k2
			temp += 1
	for i in range(a1):
		if n1 - k1 >= 0:
			n1 = n1 - k1
			temp += 1
	maxx = temp
print(minn, maxx)


from math import ceil, floor
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())

def maxKick(a1, a2, k1, k2, n):
	if k1 <= k2:
		kick1 = floor(n / k1)
		if kick1 >= a1:
			remain = n - a1 * k1
			kick2 = floor(remain / k2)
			maxKicked = a1 + kick2
		else:
			maxKicked = kick1
		return maxKicked
	else:
		return maxKick(a2, a1, k2, k1, n)

def minKick(a1, a2, k1, k2, n):
	if k1 <= k2:
		remain = n - (k2 - k1) * a2
		minKicked = max(remain - (a1 + a2) * (k1 - 1), 0)
		return minKicked
	else:
		return minKick(a2, a1, k2, k1, n)
print(minKick(a1, a2, k1, k2, n))
print(maxKick(a1, a2, k1, k2, n))


first_n = int(input())
second_n = int(input())
first_limit = int(input())
second_limit = int(input())
cards = int(input())
minimum = min(first_limit, second_limit)
maximum = 0
if cards - ((first_limit - 1) * first_n + second_n * (second_limit - 1)) > 0:
	print(cards - ((first_limit - 1) * first_n + second_n * (second_limit - 1)), end=' ')
else:
	print(0, end=' ')
if minimum == first_limit:
	while first_n and cards - first_limit >= 0:
		first_n -= 1
		cards -= first_limit
		maximum += 1
	while second_n and cards - second_limit >= 0:
		second_n -= 1
		cards -= second_limit
		maximum += 1
else:
	while second_n and cards - second_limit >= 0:
		second_n -= 1
		cards -= second_limit
		maximum += 1
	while first_n and cards - first_limit >= 0:
		first_n -= 1
		cards -= first_limit
		maximum += 1
print(maximum)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
min_a = a1 if k1 < k2 else a2
max_a = a1 if k1 > k2 else a2
min_k = min(k1, k2)
max_k = max(k1, k2)
zapas = a1 * (k1 - 1) + a2 * (k2 - 1)
min_ans = min(a1 + a2, max(0, n - zapas))
max_ans = int(n / min_k)
if max_ans > min_a:
	max_ans = min_a
	n -= min_k * min_a
	max_ans += min(max_a, int(n / max_k))
print(min_ans, max_ans)


(a, b, x, y, s) = (int(input()), int(input()), int(input()), int(input()), int(input()))
p = 0
print(max(0, s - a * (x - 1) - b * (y - 1)), end=' ')
if x < y:
	p = min(a, s // x)
	s -= p * x
	print(p + min(b, s // y))
else:
	p = min(b, s // y)
	s -= p * y
	print(p + min(a, s // x))


import math
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
min = 0
if k1 > k2:
	temp = k1
	k1 = k2
	k2 = temp
	te = a1
	a1 = a2
	a2 = te
count = 0
count = a1 * (k1 - 1) + a2 * (k2 - 1)
if count >= n:
	min = 0
else:
	min = n - count
max = 0
if n <= a1 * k1:
	max = math.floor(n / k1)
else:
	max = a1 + math.floor((n - a1 * k1) / k2)
print(min, max)


a1 = input()
a1 = int(a1)
a2 = input()
a2 = int(a2)
k1 = input()
k1 = int(k1)
k2 = input()
k2 = int(k2)
n = input()
n = int(n)
mini = 0
d = {}
d[k1] = a1
d[k2] = a2
k = 0
kk = 0
mi = n
mini = min(k1, k2)
maxi = max(k1, k2)
for i in range(1, d[mini] + 1):
	if i * mini <= n:
		k += 1
	else:
		break
mi -= k * mini
for i in range(1, d[maxi] + 1):
	if i * maxi <= mi:
		k += 1
	else:
		break
n -= (maxi - 1) * d[maxi] + (mini - 1) * d[mini]
if n <= 0:
	kk = 0
else:
	for i in range(1, d[maxi] + d[mini] + 1):
		n -= 1
		if n >= 0:
			kk += 1
print(kk, k)


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
import math as mt
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
mod = int(1000000000.0) + 7

def power(k, n):
	if n == 0:
		return 1
	if n % 2:
		return power(k, n - 1) * k % mod
	t = power(k, n // 2)
	return t * t % mod

def totalPrimeFactors(n):
	count = 0
	if n % 2 == 0:
		count += 1
		while n % 2 == 0:
			n //= 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			count += 1
			while n % i == 0:
				n //= i
		i += 2
	if n > 2:
		count += 1
	return count

def main():
	a1 = int(input())
	a2 = int(input())
	k1 = int(input())
	k2 = int(input())
	n = int(input())
	t = (k2 - 1) * a2 + (k1 - 1) * a1
	print(max(0, min(a1 + a2, n - t)), end=' ')
	if k1 > k2:
		(k1, k2) = (k2, k1)
		(a1, a2) = (a2, a1)
	ans = 0
	for i in range(a1):
		if n >= k1:
			ans += 1
			n -= k1
	for i in range(a2):
		if n >= k2:
			ans += 1
			n -= k2
	print(ans)
	return
main()


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())

def st(a, k, n):
	if a * k >= n:
		return n // k
	return a
if k2 > k1:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
mi = max(0, n - (k1 - 1) * a1 - (k2 - 1) * a2)
ma = st(a2, k2, n)
na = n - ma * k2
ma += st(a1, k1, na)
print(mi, ma)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mx = 0
nn = n
if k1 < k2:
	d1 = n // k1
	if d1 >= a1:
		n -= a1 * k1
		mx += a1
	else:
		n -= d1 * k1
		mx += d1
	d2 = n // k2
	if d2 >= a2:
		n -= a2 * k2
		mx += a2
	else:
		n -= d2 * k2
		mx += d2
else:
	d2 = n // k2
	if d2 >= a2:
		n -= a2 * k2
		mx += a2
	else:
		n -= d2 * k2
		mx += d2
	d1 = n // k1
	if d1 >= a1:
		n -= a1 * k1
		mx += a1
	else:
		n -= d1 * k1
		mx += d1
mi = 0
k1 -= 1
k2 -= 1
n = nn
n -= a1 * k1 + a2 * k2
if n <= 0:
	mi = 0
elif n >= a1 + a2:
	mi = a1 + a2
else:
	mi = n
print(mi, mx)


import sys
input = sys.stdin.readline
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 <= k2:
	if k1 == k2:
		if a1 < a2:
			(a1, a2) = (a2, a1)
	maxx = min(n // k1, a1)
	n2 = n - maxx * k1
	maxx += min(n2 // k2, a2)
else:
	maxx = min(n // k2, a2)
	n2 = n - maxx * k2
	maxx += min(n2 // k1, a1)
minn = max(n - (k1 - 1) * a1 - (k2 - 1) * a2, 0)
print(minn, maxx)


def get_int():
	return int(input())
a1 = get_int()
a2 = get_int()
k1 = get_int()
k2 = get_int()
n = get_int()
if k2 > k1:
	temp = a1
	a1 = a2
	a2 = temp
temp = k1
k1 = max(k1, k2)
k2 = min(temp, k2)
max_val = 0
min_val = 0
n_min = n - (a1 + a2) * (k2 - 1) - a1 * (k1 - k2)
n_min = max(0, n_min)
n_max = 0
if n <= a2 * k2:
	n_max = int(n / k2)
else:
	n_max = a2
	current_n = n - k2 * a2
	while current_n >= k1:
		current_n -= k1
		n_max += 1
print(n_min, n_max)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
minn = 0
if k1 < k2:
	maxn = min(a1, int(n / k1))
	n1 = n - maxn * k1
	maxn += int(n1 / k2)
else:
	maxn = min(a2, int(n / k2))
	n1 = n - maxn * k2
	maxn += int(n1 / k1)
minn = max(0, n - a1 * (k1 - 1) - a2 * (k2 - 1))
print(minn, maxn)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
curr_cards = n
curr_cards -= (k1 - 1) * a1 + (k2 - 1) * a2
minimum = 0
if curr_cards > 0:
	minimum = curr_cards
curr_cards = n
remaining_cards = 0
maximum = 0
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
remaining_cards += curr_cards % k1
curr_cards -= curr_cards % k1
div = curr_cards / k1
maximum += min(div, a1)
remaining_cards += (div - min(div, a1)) * k1
maximum += remaining_cards // k2
print(minimum, int(maximum))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
q = n - (a1 * (k1 - 1) + a2 * (k2 - 1))
if q < 0:
	q = 0
if n <= a1 * k1:
	w = n // k1
else:
	w = a1 + (n - a1 * k1) // k2
print(q, w)


a = int(input())
b = int(input())
k1 = int(input())
k2 = int(input())
n = m = int(input())
k3 = (k1 - 1) * a
k4 = (k2 - 1) * b
k5 = k3 + k4
if n >= k5:
	print(n - k5, end=' ')
else:
	print(0, end=' ')
s = 0
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a, b) = (b, a)
if n <= a * k1:
	print(n // k1)
else:
	print(a + (n - a * k1) // k2)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
m1 = 0
t = a1 * (k1 - 1) + a2 * (k2 - 1)
if t < n:
	m1 = n - t
m2 = 0
if k1 < k2:
	t = k1 * a1
	if t < n:
		m2 += a1
		n -= t
		m2 += n // k2
	else:
		m2 = n // k1
else:
	t = k2 * a2
	if t < n:
		m2 += a2
		n -= t
		m2 += n // k1
	else:
		m2 = n // k2
print(m1, m2)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
print(max(n - ((k1 - 1) * a1 + (k2 - 1) * a2), 0), end=' ')
if k1 < k2:
	spent = min(k1 * a1, n)
	ss = (n - spent) // k2
	print(spent // k1 + ss)
else:
	spent = min(k2 * a2, n)
	ss = (n - spent) // k1
	print(spent // k2 + ss)


mod = 10 ** 9 + 7
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
import collections
import math

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	a1 = int(input())
	a2 = int(input())
	k1 = int(input())
	k2 = int(input())
	n = int(input())
	if k2 < k1:
		(k1, k2) = (k2, k1)
		(a1, a2) = (a2, a1)
	ans = 0
	x = a1 * k1
	x = min(x, n)
	ans += x // k1
	m = n - x
	x = a2 * k2
	x = min(x, m)
	ans += x // k2
	p = (k1 - 1) * a1 + (k2 - 1) * a2
	nn = n - p
	nn = max(0, nn)
	ans2 = min(a1 + a2, nn)
	print(ans2, ans)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 > k2:
	(a1, a2) = (a2, a1)
	(k1, k2) = (k2, k1)
x = n // a2
y = n // k1
ma = y if a1 >= y else a1
k = n - ma * k1
x1 = k // k2
ma += x1
m = max(0, n - (k1 - 1) * a1 - (k2 - 1) * a2)
print(m, ma)


n_first = int(input())
n_second = int(input())
cards_first = int(input())
cards_second = int(input())
cards_all = int(input())
mini_team = 0
mini_cards = 0
maxi_cards = 0
if cards_first > cards_second:
	mini_team = n_second
	mini_cards = cards_second
	maxi_cards = cards_first
else:
	mini_team = n_first
	mini_cards = cards_first
	maxi_cards = cards_second
maxi = 0
for i in range(mini_team + 1):
	if cards_all < mini_cards * i:
		break
	count = i + (cards_all - mini_cards * i) // maxi_cards
	if count >= maxi:
		maxi = count
minimum = 9999
first_not = cards_first - 1
second_not = cards_second - 1
cards_all -= first_not * n_first
if second_not > 0:
	cards_all -= second_not * n_second
if cards_all < 0:
	minimum = 0
else:
	minimum = cards_all
print(minimum, maxi)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 >= k2:
	kg = k1
	ks = k2
else:
	kg = k2
	ks = k1
if kg == k1:
	ag = a1
	aas = a2
else:
	ag = a2
	aas = a1
q1 = int(n / ks)
if q1 <= aas:
	q2 = int(n / ks)
else:
	q2 = aas
rm1 = n - q2 * ks
q3 = int(rm1 / kg)
mx = q2 + q3
spd = ag * (kg - 1) + aas * (ks - 1)
if spd < n:
	mi = n - spd
else:
	mi = 0
print(mi, mx)


team1 = int(input())
team2 = int(input())
card1 = int(input())
card2 = int(input())
yellowcards = int(input())
minn = max(0, yellowcards - team1 * (card1 - 1) - team2 * (card2 - 1))
maxx = 0
if card1 < card2:
	while yellowcards >= card1 and team1 > 0:
		maxx += 1
		yellowcards -= card1
		team1 -= 1
	while yellowcards >= card2 and team2 > 0:
		maxx += 1
		yellowcards -= card2
		team2 -= 1
else:
	while yellowcards >= card2 and team2 > 0:
		maxx += 1
		yellowcards -= card2
		team2 -= 1
	while yellowcards >= card1 and team1 > 0:
		maxx += 1
		yellowcards -= card1
		team1 -= 1
print(minn, maxx)


import sys

def main():
	a1 = int(sys.stdin.readline().strip())
	a2 = int(sys.stdin.readline().strip())
	k1 = int(sys.stdin.readline().strip())
	k2 = int(sys.stdin.readline().strip())
	n = int(sys.stdin.readline().strip())
	for _ in range(1):
		if k1 > k2:
			(k1, k2) = (k2, k1)
			(a1, a2) = (a2, a1)
		amin = max(0, n - a1 * (k1 - 1) - a2 * (k2 - 1))
		amax = 0
		if a1 * k1 >= n:
			amax += n // k1
			n = 0
		else:
			amax += a1
			n -= a1 * k1
		if a2 * k2 >= n:
			amax += n // k2
			n = 0
		else:
			amax += a2
			n -= a2 * k1
		print(amin, amax)
main()


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
minimum = max(0, n - (a1 * (k1 - 1) + a2 * (k2 - 1)))
if k1 < k2:
	maximum = min(a1, n // k1)
	n = n - maximum * k1
else:
	maximum = min(a2, n // k2)
	n = n - maximum * k2
if n > 0:
	maximum = maximum + n // max(k1, k2)
print(minimum, maximum)


II = lambda : int(input())
a1 = II()
a2 = II()
k1 = II()
k2 = II()
n = II()
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
auxM = min(a1, n // k1)
restM = n - auxM * k1
M = auxM + min(a2, restM // k2)
if (k1 - 1) * a1 + (k2 - 1) * a2 >= n:
	m = 0
else:
	m = n - ((k1 - 1) * a1 + (k2 - 1) * a2)
print(m, M)


from collections import Counter
import bisect
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k2 < k1:
	(k2, k1) = (k1, k2)
	(a2, a1) = (a1, a2)
t1 = k1 * a1
t2 = k2 * a2
maxx = min(a1, n // k1)
var = n - maxx * k1
maxx += min(a2, var // k2)
n -= a1 * (k1 - 1)
n -= a2 * (k2 - 1)
minn = min(a1 + a2, max(0, n))
print(int(min(minn, a1 + a2)), int(min(maxx, a1 + a2)))


(a1, a2, k1, k2, n) = (int(input()), int(input()), int(input()), int(input()), int(input()))
m = min(k1, k2)
if m == k1:
	a = a1
else:
	a = a2
if n < (k1 - 1) * a1 + (k2 - 1) * a2:
	mini = 0
else:
	mini = n - ((k1 - 1) * a1 + (k2 - 1) * a2)
i = 0
while n >= 0:
	if i < a:
		n = n - m
		i += 1
	else:
		n = n - (k1 + k2 - m)
		i += 1
print(mini, i - 1)


import sys
import math
from itertools import combinations
from collections import defaultdict
from collections import Counter
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
d = {}
d[k1] = a1
d[k2] = a2
t1 = (k1 - 1) * a1
t2 = (k2 - 1) * a2
m1 = 0
m2 = 0
if t1 + t2 < n:
	m1 = min(n - (t1 + t2), a1 + a2)
k11 = min(k1, k2)
m2 += min(n // k11, d[k11])
n -= m2 * k11
m2 += min(d[max(k1, k2)], n // max(k1, k2))
print(m1, m2)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
max_with_0 = (k1 - 1) * a1 + (k2 - 1) * a2
min_ = max(0, n - max_with_0)
max_ = 0
max_ += min(a1, int(n / k1))
max_ += int((n - max_ * k1) / k2)
print(min_, max_)


x = []
for _ in range(5):
	x.append(int(input()))
if x[3] > x[2]:
	(x[2], x[3]) = (x[3], x[2])
	(x[0], x[1]) = (x[1], x[0])
minn = x[4] - ((x[2] - 1) * x[0] + (x[3] - 1) * x[1])
if minn < 0:
	print(0)
elif minn > x[0] + x[1]:
	print(x[0] + x[1])
else:
	print(minn)
if x[4] <= x[3] * x[1]:
	print(x[4] // x[3])
elif x[4] >= x[3] * x[1] + x[2] * x[0]:
	print(x[0] + x[1])
else:
	print((x[4] - x[3] * x[1]) // x[2] + x[1])


import sys
import math
import functools
from collections import deque
sin = sys.stdin

def rint():
	return int(sin.readline())

def rstr():
	return sin.readline()[:-1]

def rints():
	return [int(x) for x in sin.readline().split()]

def rlineints(lines):
	arr = []
	for _ in range(lines):
		arr.append(int(sin.readline()))
	return arr

def rstrs():
	return [x for x in sin.readline().split()]

def rlinestrings(lines):
	arr = []
	for _ in range(lines):
		arr.append(sin.readline()[:-1])
	return arr
t1 = rint()
t2 = rint()
k1 = rint()
k2 = rint()
n = rint()
n1 = n
n2 = n
if k2 < k1:
	hold = k2
	k2 = k1
	k1 = hold
	hold = t2
	t2 = t1
	t1 = hold
mcards = 0
if t1 * k1 <= n1:
	mcards += t1
	n1 -= t1 * k1
else:
	mcards += n1 // k1
	n1 -= n1 // k1 * k1
if t2 * k2 <= n1:
	mcards += t2
else:
	mcards += n1 // k2
mincards = 0
handout = (k1 - 1) * t1 + (k2 - 1) * t2
n -= handout
if n >= 0:
	mincards = min(n, t1 + t2)
print(mincards, mcards)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
print(max(0, n - (k1 - 1) * a1 - (k2 - 1) * a2))
if k1 < k2:
	if n // k1 <= a1:
		print(n // k1)
	else:
		print(a1 + (n - a1 * k1) // k2)
elif n // k2 <= a2:
	print(n // k2)
else:
	print(a2 + (n - a2 * k2) // k1)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mi = n - (a1 * (k1 - 1) + a2 * (k2 - 1))
if mi < 0:
	mi = 0
if k2 > k1:
	if k1 * a1 >= n:
		ma = n // k1
	else:
		ma = a1 + (n - k1 * a1) // k2
elif k2 * a2 >= n:
	ma = n // k2
else:
	ma = a2 + (n - k2 * a2) // k1
print(mi, ma, end=' ')


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
k3 = max(k1, k2)
k4 = min(k1, k2)
if k3 == k1:
	a3 = a1
	a4 = a2
else:
	a3 = a2
	a4 = a1
mi = max(n - (a3 * (k3 - 1) + a4 * (k4 - 1)), 0)
if n // k4 <= a4:
	ma = n // k4
else:
	ma = a4 + (n - a4 * k4) // k3
print(mi, ma)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
n1 = n
a = [(k1, a1), (k2, a2)]
a.sort()
rem = n // a[0][0]
if rem <= a[0][1]:
	ans1 = rem
else:
	ans1 = a[0][1]
	n -= a[0][0] * a[0][1]
	rem = n // a[1][0]
	ans1 += min(a[1][1], rem)
n1 -= (a[0][0] - 1) * a[0][1] + (a[1][0] - 1) * a[1][1]
if n1 > 0:
	print(n1, end=' ')
else:
	print(0, end=' ')
print(ans1)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if n == a1 * k1 + a2 * k2:
	mini = a1 + a2
	maxi = a1 + a2
if n < a1 * (k1 - 1) + a2 * (k2 - 1):
	mini = 0
else:
	mini = n - (a1 * (k1 - 1) + a2 * (k2 - 1))
if k1 > k2:
	if a2 * k2 < n:
		maxi = a2 + int((n - k2 * a2) / k1)
	else:
		maxi = int(n / k2)
elif a1 * k1 < n:
	maxi = a1 + int((n - k1 * a1) / k2)
else:
	maxi = int(n / k1)
print(mini)
print(maxi)


import math
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
arr = list()
if k1 < k2:
	for i in range(a1):
		arr.append(k1)
	for i in range(a1, a2 + a1):
		arr.append(k2)
else:
	for i in range(a2):
		arr.append(k2)
	for i in range(a2, a1 + a2):
		arr.append(k1)
mini = 0
maxa = 0
if n <= a1 * (k1 - 1) + a2 * (k2 - 1):
	mini = 0
	for j in range(a1 + a2):
		if n - arr[j] >= 0:
			maxa += 1
			n = n - arr[j]
		else:
			break
elif n >= a1 * k1 + a2 * k2:
	mini = a1 + a2
	maxa = a1 + a2
else:
	mini = n - a1 * (k1 - 1) - a2 * (k2 - 1)
	for j in range(a1 + a2):
		if n - arr[j] >= 0:
			maxa += 1
			n = n - arr[j]
		else:
			break
print(mini, maxa)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
l = []
for i in range(a1):
	l.append(k1)
for i in range(a2):
	l.append(k2)
min = sum(l) - len(l)
max = sum(l)
if n <= min:
	min_ans = 0
elif n <= max:
	min_ans = n - min
else:
	min_ans = a1 + a2
l.sort()
i = 0
if n >= max:
	max_ans = a1 + a2
else:
	while n > 0:
		n -= l[i]
		i += 1
	if n == 0:
		max_ans = i
	else:
		max_ans = i - 1
print(f'{min_ans} {max_ans}')


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
c = (k1 - 1) * a1 + (k2 - 1) * a2
if c >= n:
	MIN = 0
else:
	MIN = min(n - c, a1 + a2)
if k1 >= k2:
	if a2 * k2 >= n:
		MAX = n // k2
	else:
		MAX = a2 + min(a1, (n - k2 * a2) // k1)
elif a1 * k1 >= n:
	MAX = n // k1
else:
	MAX = a1 + min(a2, (n - k1 * a1) // k2)
print(*[MIN, MAX], sep=' ')


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
cards = ((k1, a1), (k2, a2))

def MAX(n, cards):
	if cards[0][0] < cards[1][0]:
		Min = 0
		Max = 1
	else:
		Min = 1
		Max = 0
	first = n // cards[Min][0]
	if first > cards[Min][1]:
		n -= cards[Min][1] * cards[Min][0]
		second = n // cards[Max][0]
		return cards[Min][1] + second
	else:
		return first

def MIN(n, cards):
	least = (cards[0][0] - 1) * cards[0][1] + (cards[1][0] - 1) * cards[1][1]
	if n <= least:
		return 0
	else:
		return n - least
print(MIN(n, cards), MAX(n, cards))


a = int(input())
b = int(input())
c = int(input())
d = int(input())
n = int(input())
if c > d:
	(c, d) = (d, c)
	(a, b) = (b, a)
m = n - (a * (c - 1) + b * (d - 1))
if m < 0:
	m = 0
if a * c >= n:
	max = n // c
else:
	max = a + (n - a * c) // d
print(m, max)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
n = int(input())
mi = 10 ** 100
ma = -1
t = a * (c - 1) + b * (d - 1)
mi = max(n - t, 0)
if d > c:
	(c, d) = (d, c)
	(a, b) = (b, a)
if b * d <= n:
	counter = b
	n -= b * d
	counter += min(a, n // c)
else:
	counter = n // d
print(mi, counter)


from math import *
from bisect import *
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
(maxx, minn) = (0, 1230120)
if k1 < k2:
	if n // k1 > a1:
		maxx += a1
		maxx += min((n - k1 * a1) // k2, a2)
	else:
		maxx += n // k1
elif n // k2 > a2:
	maxx += a2
	maxx += min((n - k2 * a2) // k1, a1)
else:
	maxx += n // k2
n -= (k1 - 1) * a1 + (k2 - 1) * a2
if n <= 0:
	minn = 0
else:
	minn = n
print(minn, maxx)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
n_cpy = n
if k1 > k2:
	(a1, a2) = (a2, a1)
	(k1, k2) = (k2, k1)
deleted_in_1 = min(a1, n // k1)
n -= k1 * deleted_in_1
deleted_in_2 = min(a2, n // k2)
deleted_max = deleted_in_1 + deleted_in_2
n = n_cpy
delta_before_deletion = min(n, a1 * (k1 - 1) + a2 * (k2 - 1))
n -= delta_before_deletion
deleted_min = n
print(deleted_min, deleted_max)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
nn = n - a1 * (k1 - 1) - a2 * (k2 - 1)
mini = min(a1 + a2, max(0, nn))
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
odp = 0
while n >= k1 and a1 > 0:
	n -= k1
	a1 -= 1
	odp += 1
while n >= k2 and a2 > 0:
	n -= k2
	a2 -= 1
	odp += 1
print(mini, odp)


num1 = int(input())
num2 = int(input())
k1 = int(input())
k2 = int(input())
total = int(input())
if k1 > k2:
	(k1, k2) = (k2, k1)
	(num1, num2) = (num2, num1)
if total <= k1 * num1:
	ansmax = total // k1
else:
	ansmax = num1
	copy = total
	copy -= k1 * num1
	ansmax += copy // k2
div = (k1 - 1) * num1 + (k2 - 1) * num2
if total <= div:
	ansmin = 0
else:
	ansmin = total - div
print(ansmin, ansmax)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
tmp = n
if k1 <= k2:
	count = 0
	for i in range(a1):
		if n - k1 >= 0:
			n -= k1
			count += 1
		else:
			break
	for i in range(a2):
		if n - k2 >= 0:
			n -= k2
			count += 1
		else:
			break
	for i in range(a2):
		if tmp - (k2 - 1) >= 0:
			tmp -= k2 - 1
		else:
			tmp = 0
	if tmp != 0:
		for i in range(a1):
			if tmp - (k1 - 1) >= 0:
				tmp -= k1 - 1
			else:
				tmp = 0
	mx = count
	mn = tmp
elif k1 > k2:
	count = 0
	for i in range(a2):
		if n - k2 >= 0:
			n -= k2
			count += 1
		else:
			break
	for i in range(a1):
		if n - k1 >= 0:
			n -= k1
			count += 1
		else:
			break
	for i in range(a1):
		if tmp - (k1 - 1) >= 0:
			tmp -= k1 - 1
		else:
			tmp = 0
	if tmp != 0:
		for i in range(a2):
			if tmp - (k2 - 1) >= 0:
				tmp -= k2 - 1
			else:
				tmp = 0
	mx = count
	mn = tmp
print(mn, mx)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
A = max(0, n - ((k1 - 1) * a1 + (k2 - 1) * a2))
if k1 <= k2:
	x = min(a1, n // k1)
	y = min(a2, (n - k1 * x) // k2)
	B = x + y
else:
	x = min(a2, n // k2)
	y = min(a1, (n - k2 * x) // k1)
	B = x + y
print(A, B)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mi = a1 + a2
ma = 0
if k1 < k2:
	ma += min(a1, n // k1)
	if n // k1 > a1:
		ma += (n - a1 * k1) // k2
else:
	ma += min(a2, n // k2)
	if n // k2 > a2:
		ma += (n - a2 * k2) // k1
ma = min(ma, a1 + a2)
maxn = a1 * (k1 - 1) + a2 * (k2 - 1)
if n <= maxn:
	mi = 0
else:
	mi = n - maxn
mi = min(mi, a1 + a2)
print(mi, ma)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
t = n
t -= a1 * (k1 - 1)
t -= a2 * (k2 - 1)
if t <= 0:
	print(0, end=' ')
else:
	print(t, end=' ')
t = n
ans = 0
if k1 < k2:
	while t >= k1 and a1 > 0:
		t -= k1
		a1 -= 1
		ans += 1
	while t >= k2 and a2 > 0:
		t -= k2
		a2 -= 1
		ans += 1
else:
	while t >= k2 and a2 > 0:
		t -= k2
		a2 -= 1
		ans += 1
	while t >= k1 and a1 > 0:
		t -= k1
		a1 -= 1
		ans += 1
print(ans)


import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

def lis():
	return [int(i) for i in input().split()]

def value():
	return int(input())
a1 = value()
a2 = value()
k1 = value()
k2 = value()
n = value()
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
tot = 0
temp = n
if n > a1 * k1:
	tot += a1
	n -= a1 * k1
	if n > a2 * k2:
		tot += a2
	else:
		tot += n // k2
else:
	tot += n // k1
ans1 = tot
tot = 0
n = temp
n -= (k1 - 1) * a1
n -= (k2 - 1) * a2
if n > 0:
	ans2 = min(a1 + a2, n)
else:
	ans2 = 0
print(min(ans1, ans2), max(ans2, ans1))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
t = a1 * (k1 - 1) + a2 * (k2 - 1)
if t >= n:
	nd = 0
else:
	nd = n - t
if k1 > k2:
	(a1, a2) = (a2, a1)
	(k1, k2) = (k2, k1)
if n == a1 * k1 + a2 * k2:
	d = a1 + a2
else:
	d = 0
	if n < k1:
		pass
	elif n // k1 > a1:
		d += a1
		n -= a1 * k1
		d += n // k2
	else:
		d += n // k1
print(nd, d)


a_1 = int(input())
a_2 = int(input())
k_1 = int(input())
k_2 = int(input())
n = int(input())
out_min = max(0, n - a_1 * (k_1 - 1) - a_2 * (k_2 - 1))
if k_1 <= k_2:
	a_min = a_1
	k_min = k_1
	a_max = a_2
	k_max = k_2
else:
	a_min = a_2
	k_min = k_2
	a_max = a_1
	k_max = k_1
out_max = min(n // k_min, a_min)
out_max += min((n - out_max * k_min) // k_max, a_max)
print(out_min, out_max)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
N = int(input())
m2 = 0
t = N
if k1 < k2:
	m2 += min(a1, N // k1)
	t -= min(a1, N // k1) * k1
	m2 += min(a2, t // k2)
else:
	m2 += min(a2, N // k2)
	t -= min(a2, N // k2) * k2
	m2 += min(a1, t // k1)
N -= a1 * (k1 - 1) + a2 * (k2 - 1)
print(min(a1 + a2, max(N, 0)), m2)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mn = 0
mx = 0
if n > a1 * (k1 - 1) + a2 * (k2 - 1):
	mn = min(a1 + a2, n - (a1 * (k1 - 1) + a2 * (k2 - 1)))
if k1 > k2:
	mx += min(a2, n // k2)
	n -= mx * k2
	mx += min(a1, n // k1)
else:
	mx += min(a1, n // k1)
	n -= mx * k1
	mx += min(a2, n // k2)
print(mn, mx)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
c = a1 * (k1 - 1) + a2 * (k2 - 1)
ming = 0
maxg = 0
if n - c <= 0:
	ming = 0
else:
	ming = n - c
if a1 * k1 >= n:
	maxg = n // k1
else:
	maxg = a1 + (n - a1 * k1) // k2
print(ming, maxg)


a = int(input())
b = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if (k1 - 1) * a + (k2 - 1) * b < n:
	m1 = n - ((k1 - 1) * a + (k2 - 1) * b)
else:
	m1 = 0
ans = k1 * a + k2 * b
m2 = a + b
if k1 >= k2:
	x = k1
	xa = a
	y = k2
	yb = b
else:
	x = k2
	xa = b
	y = k1
	yb = a
while ans > n:
	if xa != 0:
		ans = ans - x
		xa = xa - 1
		m2 -= 1
	elif yb != 0:
		ans = ans - y
		yb -= 1
		m2 -= 1
	else:
		m2 = 0
print(m1, m2)


gi = lambda : list(map(int, input().split()))
(a, b, x, y, n) = [gi()[0] for _ in range(5)]
l = [x for _ in range(a)]
l += [y for _ in range(b)]
l.sort()
mi = 0
nn = n
cur = 0
while nn:
	if nn < l[cur]:
		break
	nn -= l[cur]
	mi += 1
	cur += 1
nn = n
nn -= (x - 1) * a + (y - 1) * b
ma = 0
for k in range(a + b):
	if nn <= 0:
		break
	nn -= 1
	ma += 1
print(ma, mi)


t1 = int(input())
t2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
m1 = int
m1 = 0
m2 = int
m2 = 0
n1 = n
l = [0] * 2
if k1 <= k2:
	ans = int(n / k1)
	if ans >= t1:
		m1 += t1
		n -= t1 * k1
	else:
		m1 += ans
		n -= ans * k1
	ans = int(n / k2)
	if ans >= t2:
		m1 += t2
	else:
		m1 += ans
	l[1] = m1
else:
	ans = int(n / k2)
	if ans >= t2:
		m1 += t2
		n -= t2 * k2
	else:
		m1 += ans
		n -= ans * k2
	ans = int(n / k1)
	if ans >= t1:
		m1 += t1
	else:
		m1 += ans
	l[1] = m1
if n1 <= t1 * (k1 - 1) + t2 * (k2 - 1):
	l[0] = 0
else:
	l[0] = n1 - (t1 * (k1 - 1) + t2 * (k2 - 1))
print(' '.join(map(str, l)))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
k = min(k1, k2)
a = a1 + a2
if k == k1:
	if a1 >= n // k1:
		MAX = n // k1
	else:
		MAX = a1 + (n - k1 * a1) // k2
	if n <= a1 * k1 + k2 * a2 - a1 - a2:
		MIN = 0
	else:
		MIN = n - (a1 * k1 + k2 * a2 - a1 - a2)
else:
	if a2 >= n // k2:
		MAX = n // k2
	else:
		MAX = a2 + (n - k2 * a2) // k1
	if n <= a1 * k1 + k2 * a2 - a1 - a2:
		MIN = 0
	else:
		MIN = n - (a1 * k1 + k2 * a2 - a1 - a2)
if MAX > a:
	MAX = a
if MIN < 0:
	MIN = 0
print(MIN, MAX)


(a, b, k, l, n) = (int(input()), int(input()), int(input()), int(input()), int(input()))
if n >= a * k + b * l:
	print(a + b, a + b)
else:
	s = (k - 1) * a + (l - 1) * b
	print(max(0, n - s), end=' ')
	if k >= l:
		if n // l <= b:
			print(n // l)
		else:
			print(b + (n - b * l) // k)
	elif n // k <= a:
		print(n // k)
	else:
		print(a + (n - a * k) // l)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mn = 0
mx = 0
mx = max(min(n // k2, a2) + min((n - min(n // k2, a2) * k2) // k1, a1), min(n // k1, a1) + min((n - min(n // k1, a1) * k1) // k2, a2))
mn = max(0, min(n - (a1 * (k1 - 1) + a2 * (k2 - 1)), a1 + a2))
print(mn, mx)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
data = {k1: a1, k2: a2}
max_k = max(k1, k2)
min_k = min(k1, k2)
m = n
m -= (max_k - 1) * data[max_k]
m -= (min_k - 1) * data[min_k]
if m < 0:
	_min = 0
else:
	_min = m
m = n
_max = min(data[min_k], m // min_k)
m -= _max * min_k
if m > 0:
	_max += min(data[max_k], m // max_k)
print(_min, _max)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
n1 = n
maxp = 0
minp = 0
if k1 > k2:
	if n >= k2:
		x = min(n // k2, a2)
		maxp += x
		n = n - x * k2
		if n > 0:
			y = min(n // k1, a1)
			maxp += y
elif n >= k1:
	x = min(n // k1, a1)
	maxp += x
	n = n - x * k1
	if n > 0:
		y = min(n // k2, a2)
		maxp += y
if n1 > a1 * (k1 - 1) + a2 * (k2 - 1):
	n1 = n1 - (a1 * (k1 - 1) + a2 * (k2 - 1))
	minp = n1
print(minp, maxp)


(a, b, k, l, n) = (int(input()) for _ in [0] * 5)
r = range(max(0, n - b * l), min(n, a * k) + 1)
print(min((max(0, m - (k - 1) * a) + max(0, n - m - (l - 1) * b) for m in r)), max((m // k + (n - m) // l for m in r)))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mini = (k2 - 1) * a2 + (k1 - 1) * a1
if mini >= n:
	mini = 0
else:
	mini = min(n - mini, a1 + a2)
maxi = 0
m_cnt = 0
a1_ = a1
n2 = n
a2_ = a2
if k2 < k1:
	while n2 >= k2 and a2_ > 0:
		n2 -= k2
		a2_ -= 1
		m_cnt += 1
	while n2 >= k1 and a1_ > 0:
		n2 -= k1
		a1_ -= 1
		m_cnt += 1
else:
	while n2 >= k1 and a1_ > 0:
		n2 -= k1
		a1_ -= 1
		m_cnt += 1
	while n2 >= k2 and a2_ > 0:
		n2 -= k2
		a2_ -= 1
		m_cnt += 1
maxi = m_cnt
print(mini, maxi)


def main():
	import sys
	input = sys.stdin.readline
	a1 = int(input())
	a2 = int(input())
	k1 = int(input())
	k2 = int(input())
	n = int(input())
	mi = max(0, a1 + a2 - (a1 * k1 + a2 * k2 - n))
	if k1 > k2:
		(a1, a2) = (a2, a1)
		(k1, k2) = (k2, k1)
	ma = 0
	if n >= a1 * k1:
		n -= a1 * k1
		ma += a1
		ma += n // k2
	else:
		ma = n // k1
	print(mi, ma)
	return 0
main()


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
minans = n - ((k1 - 1) * a1 + (k2 - 1) * a2)
minans = max(0, minans)
maxans = 0
if k1 < k2:
	if a1 * k1 <= n:
		n -= a1 * k1
		maxans += a1
	else:
		maxans += n // k1
		n = 0
	maxans += n // k2
else:
	if a2 * k2 <= n:
		n -= a2 * k2
		maxans += a2
	else:
		maxans += n // k2
		n = 0
	maxans += n // k1
print(minans, maxans)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
n_max = n
mi = 0
ma = 0
n_max = n - (k1 - 1) * a1 - (k2 - 1) * a2
if n_max <= 0:
	mi = 0
else:
	mi = n_max
if k1 <= k2:
	play = int(n / k1)
	if play <= a1:
		ma += play
	else:
		play = a1
		ma += a1
		n -= play * k1
		play = int(n / k2)
		if play <= a2:
			ma += play
		else:
			ma += a2
else:
	play = int(n / k2)
	if play <= a2:
		ma += play
	else:
		play = a2
		ma += a2
		n -= play * k2
		play = int(n / k1)
		if play <= a1:
			ma += play
		else:
			ma += a1
print(f'{mi} {ma}')


import math
(a1, a2, k1, k2, n) = (int(input()), int(input()), int(input()), int(input()), int(input()))
sl = min(k1, k2)
(large, small) = (0, 0)
p = n
if sl == k1:
	large += min(int(n / k1), a1)
	n -= large * k1
	large += min(int(n / k2), a2)
else:
	large += min(int(n / k2), a2)
	n -= large * k2
	large += min(int(n / k1), a1)
if sl == k2:
	if k1 != 1:
		p -= min(math.ceil(p / (k1 - 1)), a1) * (k1 - 1)
	if k2 != 1:
		p -= min(math.ceil(p / (k2 - 1)), a2) * (k2 - 1)
else:
	if k2 != 1:
		p -= min(math.ceil(p / (k2 - 1)), a2) * (k2 - 1)
	if k1 != 1 and p > 0:
		p -= min(math.ceil(p / (k1 - 1)), a1) * (k1 - 1)
if p < 0:
	small = 0
else:
	small = int(p)
print(small, large)


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue import PriorityQueue as pq
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 > k2:
	(a1, a2) = (a2, a1)
	(k1, k2) = (k2, k1)
(x, y) = (0, 0)
if n == a1 * k1 + a2 * k2:
	print(a1 + a2, a1 + a2)
else:
	a = n
	a -= a2 * (k2 - 1)
	a -= a1 * (k1 - 1)
	if a <= 0:
		x = 0
	else:
		x = a
	y = 0
	a = n
	while a > 0 and a1:
		if a - k1 >= 0:
			y += 1
			a -= k1
			a1 -= 1
		else:
			a = 0
	while a > 0 and a2:
		if a - k2 >= 0:
			y += 1
			a -= k2
			a2 -= 1
		else:
			a = 0
	print(x, y)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
min_players = max(0, n - (a2 * (k2 - 1) + a1 * (k1 - 1)))
max_players = 0
cards_left = n
if k1 > k2:
	t = k1
	k1 = k2
	k2 = t
	t = a1
	a1 = a2
	a2 = t
while a1 > 0 and cards_left - k1 >= 0:
	max_players += 1
	a1 -= 1
	cards_left -= k1
while a2 > 0 and cards_left - k2 >= 0:
	max_players += 1
	a2 -= 1
	cards_left -= k2
print(min_players, max_players)


a = int(input())
aa = int(input())
b = int(input())
bb = int(input())
n = int(input())
s = []
maxx = 0
minn = 0
minnb = 0
maxxb = 0
minna = 0
maxxa = 0
if b < bb:
	minnb = b
	maxxb = bb
	minna = a
	maxxa = aa
else:
	minnb = bb
	maxxb = b
	minna = aa
	maxxa = a
nn = n
if n > minnb * minna:
	maxx += minna
	n -= minnb * minna
	maxx += n // maxxb
else:
	maxx = n // minnb
if nn <= a * (b - 1) + aa * (bb - 1):
	minn = 0
else:
	minn = nn - (a * (b - 1) + aa * (bb - 1))
print(minn, maxx)


from sys import stdin
a1 = int(stdin.readline().strip())
a2 = int(stdin.readline().strip())
k1 = int(stdin.readline().strip())
k2 = int(stdin.readline().strip())
n = int(stdin.readline().strip())
a11 = a1
a22 = a2
k11 = k1
k22 = k2
n1 = max(0, n - (k1 - 1) * a1 - (k2 - 1) * a2)
mx = min(n1, a1 + a2)
mn = 0
k11 = min(k1, k2)
if k11 == k1:
	mn += min(a1, n // k1)
	n -= mn * k1
	mn += min(a2, n // k2)
elif k11 == k2:
	mn += min(a2, n // k2)
	n -= mn * k2
	mn += min(a1, n // k1)
print(mx, mn)


from sys import stdin, stdout
import heapq
import cProfile, math
from collections import Counter, defaultdict, deque
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
import sys
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
fac_warm_up = False
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7

class MergeFind:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n
		self.lista = [[_] for _ in range(n)]

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]
		self.lista[a] += self.lista[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def prime_factors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def all_factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def fibonacci_modP(n, MOD):
	if n < 2:
		return 1
	return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD

def factorial_modP_Wilson(n, p):
	if p <= n:
		return 0
	res = p - 1
	for i in range(n + 1, p):
		res = res * cached_fn(InverseEuler, i, p) % p
	return res

def binary(n, digits=20):
	b = bin(n)[2:]
	b = '0' * (digits - len(b)) + b
	return b

def is_prime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def generate_primes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	return prime
factorial_modP = []

def warm_up_fac(MOD):
	global factorial_modP, fac_warm_up
	if fac_warm_up:
		return
	factorial_modP = [1 for _ in range(fac_warm_up_size + 1)]
	for i in range(2, fac_warm_up_size):
		factorial_modP[i] = factorial_modP[i - 1] * i % MOD
	fac_warm_up = True

def InverseEuler(n, MOD):
	return pow(n, MOD - 2, MOD)

def nCr(n, r, MOD):
	global fac_warm_up, factorial_modP
	if not fac_warm_up:
		warm_up_fac(MOD)
		fac_warm_up = True
	return factorial_modP[n] * (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD) % MOD) % MOD

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def display_2D_list(li):
	for i in li:
		print(i)

def prefix_sum(li):
	sm = 0
	res = []
	for i in li:
		sm += i
		res.append(sm)
	return res

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def ncr(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def binary_search(i, li):
	fn = lambda x: li[x] - x // i
	x = -1
	b = len(li)
	while b >= 1:
		while b + x < len(li) and fn(b + x) > 0:
			x += b
		b = b // 2
	return x
TestCases = False
fac_warm_up_size = 10 ** 5 + 100
optimise_for_recursion = False

def main():
	a1 = get_int()
	a2 = get_int()
	k1 = get_int()
	k2 = get_int()
	n = get_int()
	if k2 > k1:
		(a1, a2, k1, k2) = (a2, a1, k2, k1)
	mini = max(0, n - a1 * (k1 - 1) - a2 * (k2 - 1))
	if n <= a2 * k2:
		maxi = n // k2
	else:
		maxi = a2 + (n - a2 * k2) // k1
	print(mini, maxi)
if TestCases:
	for i in range(get_int()):
		main()
else:
	main() if not optimise_for_recursion else threading.Thread(target=main).start()


import math
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
minv = max(n - (k2 - 1) * a2 - (k1 - 1) * a1, 0)
maxv = 0
if k1 < k2:
	maxv = min(math.floor(n / k1), a1) + max(math.floor((n - a1 * k1) / k2), 0)
else:
	maxv = min(math.floor(n / k2), a2) + max(math.floor((n - a2 * k2) / k1), 0)
print(str(minv) + ' ' + str(maxv))


import os
import sys
from io import BytesIO, IOBase

def solution(a1, a2, k1, k2, n):
	if a1 * k1 + a2 * k2 == n:
		write(a1 + a2, a1 + a2)
		return
	if a1 * (k1 - 1) + a2 * (k2 - 1) >= n:
		best_case = 0
	else:
		best_case = abs(a1 * (k1 - 1) + a2 * (k2 - 1) - n)
	if k1 > k2:
		(a1, a2) = (a2, a1)
		(k1, k2) = (k2, k1)
	if a1 * k1 >= n:
		worst_case = n // k1
	else:
		worst_case = a1 + (n - a1 * k1) // k2
	write(best_case, worst_case)

def main():
	a1 = r_int()
	a2 = r_int()
	k1 = r_int()
	k2 = r_int()
	n = r_int()
	solution(a1, a2, k1, k2, n)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
import itertools

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	a1 = Int()
	a2 = Int()
	k1 = Int()
	k2 = Int()
	n = Int()
	if k1 > k2:
		(k1, k2) = (k2, k1)
		(a1, a2) = (a2, a1)
	mini = max(0, n - (a1 * (k1 - 1) + a2 * (k2 - 1)))
	if n <= a1 * k1:
		maxi = n // k1
	else:
		maxi = a1 + (n - a1 * k1) // k2
	print(mini, maxi)
solution()


first = int(input())
second = int(input())
togofirst = int(input())
togosecond = int(input())
cards = int(input())
minn = 0
maxx = 0
if cards == first * togofirst + second * togosecond:
	minn = maxx = first + second
	print(minn, maxx)
	exit()

def mx(first, second, togofirst, togosecond, cards):
	m1 = 0
	m2 = 0
	if togofirst <= togosecond:
		if cards >= first * togofirst:
			m1 += first
			cards -= first * togofirst
		else:
			m1 += cards // togofirst
			cards -= m1 * togofirst
		if cards >= second * togosecond:
			m2 += second
		else:
			m2 += cards // togosecond
		return m1 + m2
	else:
		if cards >= second * togosecond:
			m2 += second
			cards -= second * togosecond
		else:
			m2 += cards // togosecond
			cards -= m2 * togosecond
		if cards >= first * togofirst:
			m1 += first
		else:
			m1 += cards // togofirst
		return m1 + m2

def mn(first, second, togofirst, togosecond, cards):
	cards -= first * (togofirst - 1)
	cards -= second * (togosecond - 1)
	if cards >= 0:
		return cards
	else:
		return 0
maxx = mx(first, second, togofirst, togosecond, cards)
minn = mn(first, second, togofirst, togosecond, cards)
print(minn, maxx)


z = lambda : int(input())
(a, b, a1, b1, c) = (z(), z(), z(), z(), z())
print(min(a + b, max(0, c - ((a1 - 1) * a + (b1 - 1) * b))), max(min((c - a1 * min(c // a1, a)) // b1, b) + min(c // a1, a), min((c - b1 * min(c // b1, b)) // a1, a) + min(c // b1, b)))


import sys, math, queue
MOD = 10 ** 9 + 7
sys.setrecursionlimit(1000000)
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mn = max(0, n - (k1 - 1) * a1 - (k2 - 1) * a2)
if k1 <= k2:
	mx = min(n // k1, a1)
	mx += min((n - mx * k1) // k2, a2)
else:
	mx = min(n // k2, a2)
	mx += min((n - mx * k2) // k1, a1)
print(mn, mx)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
m1 = 0
val = 0
z = n
if k1 < k2:
	val = k1
	p1 = a1
	val2 = k2
	p2 = a2
else:
	val = k2
	p1 = a2
	val2 = k1
	p2 = a1
c1 = 0
c2 = 0
while n > 0 or c1 + c2 <= a1 + a2:
	if c1 + c2 >= a1 + a2:
		break
	if c1 < p1:
		if n - val < 0:
			break
		n = n - val
		c1 = c1 + 1
	else:
		if n - val2 < 0:
			break
		n = n - val2
		c2 = c2 + 1
if a1 * k1 + a2 * k2 < z:
	ans2 = a1 + a2
else:
	ans2 = z - (a1 * (k1 - 1) + a2 * (k2 - 1))
if ans2 < 0:
	ans2 = 0
print(ans2, c1 + c2)


import os
import sys
from io import BytesIO, IOBase

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()

def test():
	(a1, a2, k1, k2, n) = (int(input()), int(input()), int(input()), int(input()), int(input()))
	(mn, mx) = (0, 0)
	mn = n - (a1 * (k1 - 1) + a2 * (k2 - 1))
	mn = mn if mn >= 0 else 0
	if k1 < k2:
		if k1 * a1 < n:
			mx = a1
			mx += (n - k1 * a1) // k2
		elif k2 * a2 < n:
			mx = a2
			mx += (n - k2 * a2) // k1
		else:
			mx = n // k1
	elif k2 * a2 < n:
		mx = a2
		mx += (n - k2 * a2) // k1
	elif k1 * a1 < n:
		mx = a1
		mx += (n - k1 * a1) // k2
	else:
		mx = n // k2
	print(mn, mx)
test()


import sys
import math
input = sys.stdin.readline
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mini = 0
if (k1 - 1) * a1 + (k2 - 1) * a2 < n:
	xx = n - (k1 - 1) * a1 - (k2 - 1) * a2
	mini = min(xx, a1 + a2)
maxi = 0
if k1 > k2:
	maxi += min(n // k2, a2)
	n -= min(n // k2, a2) * k2
	maxi += min(n // k1, a1)
	n -= min(n // k1, a1) * k1
else:
	maxi += min(n // k1, a1)
	n -= min(n // k1, a1) * k1
	maxi += min(n // k2, a2)
	n -= min(n // k2, a2) * k2
print(mini, maxi)


from bisect import insort as ins
from bisect import bisect_left as bl
from collections import defaultdict as dd

def fm(k1, k2, a1, a2, n):
	if 1:
		if k2 > k1:
			(k1, k2) = (k2, k1)
			(a1, a2) = (a2, a1)
		c = 0
		while a2 and n:
			if n >= k2:
				n -= k2
				a2 -= 1
				c += 1
			else:
				break
		while a1 and n:
			if n >= k1:
				n -= k1
				a1 -= 1
				c += 1
			else:
				break
		return c

def fmm(k1, k2, a1, a2, n):
	if k2 > k1:
		(k1, k2) = (k2, k1)
		(a1, a2) = (a2, a1)
	z = a1 * (k1 - 1)
	if z >= n:
		return 0
	n -= z
	y = a2 * (k2 - 1)
	if y >= n:
		return 0
	n -= y
	return min(n, a1 + a2)
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
c = fm(k1, k2, a1, a2, n)
d = fmm(k1, k2, a1, a2, n)
print(d, c)


a = int(input())
b = int(input())
x = int(input())
y = int(input())
n = int(input())
z = n - a * (x - 1) - b * (y - 1)
t1 = min(n // x, a)
t2 = min(n // y, b)
k = max(t1 + min((n - x * t1) // y, b), t2 + min((n - y * t2) // x, a))
print(max(0, z), k)


(a1, a2) = (int(input()), int(input()))
(k1, k2) = (int(input()), int(input()))
n = int(input())
mi = max(0, n - a1 * (k1 - 1) - a2 * (k2 - 1))
if k1 > k2:
	(a1, a2, k1, k2) = (a2, a1, k2, k1)
	kk = k1
ma = n // k1
if ma > a1:
	ma = a1
n -= ma * k1
ma += n // k2
print(mi, ma)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
ans = 0
temp = 0
minn = n - a1 * (k1 - 1) - a2 * (k2 - 1)
if minn >= a1 + a2:
	minn = a1 + a2
elif minn <= 0:
	minn = 0
if k1 > k2:
	temp = n // k2
	n = n % k2
	if temp > a2:
		n += (temp - a2) * k2
		temp = a2
	temp = temp + n // k1
	maxx = temp
else:
	temp = n // k1
	n = n % k1
	if temp > a1:
		n += (temp - a1) * k1
		temp = a1
	temp = temp + n // k2
	maxx = temp
print(minn, maxx)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
q = max(0, n - ((k1 - 1) * a1 + (k2 - 1) * a2))
if k1 <= k2:
	x = min(a1, n // k1)
	y = min(a2, (n - k1 * x) // k2)
	w = x + y
else:
	x = min(a2, n // k2)
	y = min(a1, (n - k2 * x) // k1)
	w = x + y
print(q, w)


t1 = int(input())
t2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
r = 0
minplayer = t1 * k1 + t2 * k2 - n
if k1 == 1 or k2 == 1:
	if k1 > k2:
		if k1 * t1 - n >= t1:
			s = 0
		else:
			s = abs((k1 - 1) * t1 + (k2 - 1) * t2 - n)
	elif k2 * t2 - n >= t2:
		s = 0
	else:
		s = abs((k1 - 1) * t1 + (k2 - 1) * t2 - n)
elif minplayer == 0:
	s = t1 + t2
else:
	q = (k1 - 1) * t1 + (k2 - 1) * t2
	s = abs(q - n)
	if s > t1 + t2:
		s = 0
	elif q - n > 0:
		s = 0
if k1 < k2:
	g = n - t1 * k1
	if g >= 0:
		p = int(g / k2)
		r = t1 + p
	else:
		r = int(n / k1)
else:
	g = n - t2 * k2
	if g >= 0:
		p = int(g / k1)
		r = t2 + p
	else:
		r = int(n / k2)
print(f'{s} {r}')


team1 = int(input())
team2 = int(input())
max_team1 = int(input())
max_team2 = int(input())
tedad = int(input())
min_temp = team1 * (max_team1 - 1) + team2 * (max_team2 - 1)
if tedad >= min_temp:
	print(int(tedad - min_temp), end=' ')
else:
	print(0, end=' ')
if max_team1 <= max_team2:
	yellow_team = max_team1 * team1
	if yellow_team >= tedad:
		print(int(tedad / max_team1))
	else:
		print(int(team1 + (tedad - yellow_team) / max_team2))
else:
	yellow_team = max_team2 * team2
	if yellow_team >= tedad:
		print(int(tedad / max_team2))
	else:
		print(int(team2 + (tedad - yellow_team) / max_team1))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if n <= a1 * (k1 - 1) + a2 * (k2 - 1):
	print(0)
else:
	print(n - (a1 * (k1 - 1) + a2 * (k2 - 1)), end=' ')
if k2 < k1:
	t = n // k2
	if t <= a2:
		print(t)
	else:
		print(a2 + (n - k2 * a2) // k1)
else:
	t = n // k1
	if t <= a1:
		print(t)
	else:
		print(a1 + (n - k1 * a1) // k2)


def cin_int():
	return int(input())

def cin_aint():
	return map(int, input().split())

def main():
	a1 = cin_int()
	a2 = cin_int()
	k1 = cin_int()
	k2 = cin_int()
	n = cin_int()
	minim = max(n - (a1 * (k1 - 1) + a2 * (k2 - 1)), 0)
	maxim = 0
	if k1 < k2:
		p1 = n // k1
		if a1 <= p1:
			maxim += a1
			p2 = (n - a1 * k1) // k2
			if a2 <= p2:
				maxim += a2
			else:
				maxim += p2
		else:
			maxim += p1
	else:
		p2 = n // k2
		if a2 <= p2:
			maxim += a2
			p1 = (n - a2 * k2) // k1
			if a1 <= p1:
				maxim += a1
			else:
				maxim += p1
		else:
			maxim += p2
	print(str(minim) + ' ' + str(maxim))
main()


def find_max(li):
	(a1, a2, k1, k2, n) = li
	li = [(k1, a1), (k2, a2)]
	li.sort()
	max_ = n // li[0][0]
	if max_ > li[0][1]:
		remain = n - li[0][1] * li[0][0]
		val = li[0][1]
	else:
		remain = n - max_ * li[0][0]
		val = max_
	max_ = remain // li[1][0]
	if max_ > li[1][1]:
		remain = remain - li[1][1] * li[1][0]
		val += li[1][1]
	else:
		remain = remain - max_ * li[1][0]
		val += max_
	return val

def find_min(li):
	(a1, a2, k1, k2, n) = li
	sum_ = a1 * (k1 - 1) + a2 * (k2 - 1)
	if sum_ > n:
		return 0
	else:
		return n - sum_
li = [0] * 5
for i in range(0, 5):
	li[i] = int(input())
print(find_min(li), end=' ')
print(find_max(li))


n1 = int(input())
n2 = int(input())
k1 = int(input())
k2 = int(input())
y = int(input())
if k1 > k2:
	(k1, n1, k2, n2) = (k2, n2, k1, n1)
x = min(y // k1, n1)
ma = x + min((y - k1 * x) // k2, n2)
y -= (k2 - 1) * n2 + (k1 - 1) * n1
if y <= 0:
	mi = 0
else:
	mi = min(y, n1 + n2)
print(mi, ma)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
max_ = 0
min_ = 0
if k1 <= k2:
	if n <= a1 * k1:
		max_ = n // k1
	else:
		max_ += a1
		if n - a1 * k1 <= a2 * k2:
			max_ += (n - a1 * k1) // k2
		else:
			max_ += a2
elif n <= a2 * k2:
	max_ = n // k2
else:
	max_ += a2
	if n - a2 * k2 <= a1 * k1:
		max_ += (n - a2 * k2) // k1
	else:
		max_ += a1
if a1 * (k1 - 1) + a2 * (k2 - 1) < n:
	min_ = n - (a1 * (k1 - 1) + a2 * (k2 - 1))
print(min_, max_)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
H = n
minm = 0
maxm = 0
if k2 < k1:
	if n >= k2 * a2:
		maxm += a2
		n = n - k2 * a2
		if n >= k1:
			A = n // k1
			if A <= a1:
				maxm += A
			else:
				maxm += a1
	else:
		maxm += n // k2
	D = 0
	l = []
	q = []
	w = []
	n = H
	while a1:
		l.append(k1)
		a1 -= 1
		n = n - k1 + 1
		if n <= 0:
			break
	if n <= 0:
		minm = 0
	elif k2 != 1:
		while a2:
			a2 -= 1
			q.append(k2)
			n = n - k2 + 1
			if n <= 0:
				break
		if n <= 0:
			minm = 0
		else:
			minm = n
	else:
		minm = n
elif k1 < k2:
	if n >= k1 * a1:
		maxm += a1
		n = n - k1 * a1
		if n >= k2:
			A = n // k2
			if A <= a2:
				maxm += A
			else:
				maxm += a2
	else:
		maxm += n // k1
	D = 0
	l = []
	q = []
	w = []
	n = H
	while a2:
		l.append(k2)
		a2 -= 1
		n = n - k2 + 1
		if n <= 0:
			break
	if n <= 0:
		minm = 0
	elif k1 != 1:
		while a1:
			a1 -= 1
			q.append(k1)
			n = n - k1 + 1
			if n <= 0:
				break
		if n <= 0:
			minm = 0
		else:
			minm = n
	else:
		minm = n
else:
	A = n // k1
	if A <= a1:
		maxm += A
		n = n - A * k1
	else:
		maxm += a1
		n = n - a1 * k1
	B = n // k2
	if B <= a2:
		maxm += B
		n = n - B * k2
	else:
		maxm += a2
		n = n - a2 * k2
	D = 0
	l = []
	q = []
	w = []
	n = H
	while a1:
		l.append(k1)
		a1 -= 1
		n = n - k1 + 1
		if n <= 0:
			break
	if n <= 0:
		minm = 0
	elif k2 != 1:
		while a2:
			a2 -= 1
			q.append(k2)
			n = n - k2 + 1
			if n <= 0:
				break
		if n <= 0:
			minm = 0
		else:
			minm = n
	else:
		minm = n
print(minm, maxm)


(a1, a2, k1, k2, n) = (int(input()) for _ in range(5))
max_0 = a1 * (k1 - 1) + a2 * (k2 - 1)
min_count = max(n - max_0, 0)
if k1 < k2:
	if n <= a1 * k1:
		max_count = n // k1
	else:
		max_count = a1 + (n - a1 * k1) // k2
elif n <= a2 * k2:
	max_count = n // k2
else:
	max_count = a2 + (n - a2 * k2) // k1
print(min_count, max_count)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mi = max(0, n - ((k1 - 1) * a1 + (k2 - 1) * a2))
cnt = 0
kol = 0
if k2 > k1:
	(a1, a2) = (a2, a1)
	(k1, k2) = (k2, k1)
while a2 and kol + k2 <= n:
	a2 -= 1
	kol += k2
	cnt += 1
while a1 and kol + k1 <= n:
	a1 -= 1
	kol += k1
	cnt += 1
print(mi, cnt)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
waste = a * (c - 1) + b * (d - 1)
left = max(0, e - waste)
fans = min(left, a + b)
f = min(c, d)
if f == c:
	mxplo = min(a, int(e / c))
	cl = e - mxplo * c
	mxplo1 = min(b, int(cl / d))
	sans = mxplo + mxplo1
else:
	mxplo = min(b, int(e / d))
	cl = e - mxplo * d
	mxplo1 = min(a, int(cl / c))
	sans = mxplo + mxplo1
print(fans, sans)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
max = 0
min = 0
c = 1
if k1 > k2:
	for i in range(1, a2 + 1):
		if i * k2 <= n:
			c = i
			max = max + 1
		else:
			break
	for j in range(1, a1 + 1):
		if j * k1 <= n - c * k2:
			max = max + 1
		else:
			break
else:
	for i in range(1, a1 + 1):
		if i * k1 <= n:
			c = i
			max = max + 1
		else:
			break
	for j in range(1, a2 + 1):
		if j * k2 <= n - c * k1:
			max = max + 1
		else:
			break
if a1 * (k1 - 1) + a2 * (k2 - 1) < n:
	x = a1 * (k1 - 1) + a2 * (k2 - 1)
	min = n - x
print(min, end=' ')
print(max)


a = int(input())
b = int(input())
l = []
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 <= k2:
	r = n // k1
	s = n % k1
	p = a - r
	if p <= 0:
		o = a + (s - p * k1) // k2
		l.append(o)
	else:
		u = a - p + s // k2
		l.append(u)
else:
	r = n // k2
	p = n % k2
	s = b - r
	if s < 0:
		y = b + (p - s * k2) // k1
		l.append(y)
	else:
		y = b - s + p // k1
		l.append(y)
t = (k2 - 1) * b + (k1 - 1) * a
r = n - t
if n > t:
	l.append(r)
elif r > a + b:
	d = a + b
	l.append(d)
elif r <= 0:
	l.append(0)
else:
	l.append(r)
print(l[1], l[0])


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
ks = int(input())
minimo = ks - a1 * (k1 - 1) - a2 * (k2 - 1)
if minimo > a2 + a1:
	minimo = a2 + a1
elif minimo < 0:
	minimo = 0
maximo = 0
lista = []
t1 = [k1 for i in range(a1)]
t2 = [k2 for i in range(a2)]
if k1 > k2:
	lista = t2 + t1
else:
	lista = t1 + t2
for i in lista:
	if i <= ks:
		ks -= i
		maximo += 1
	if ks == 0:
		break
print(minimo, maximo)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
ans = []
if a1 * (k1 - 1) + a2 * (k2 - 1) <= n:
	ans.append(n - (a1 * (k1 - 1) + a2 * (k2 - 1)))
else:
	ans.append(0)
x = 0
count2 = 0
if k1 <= k2:
	if k1 * a1 <= n:
		count2 = a1
		x = n - k1 * a1
		count2 = count2 + x // k2
	else:
		count2 = n // k1
elif k2 * a2 <= n:
	count2 = a2
	x = n - k2 * a2
	count2 = count2 + x // k1
else:
	count2 = n // k2
ans.append(count2)
print(*ans)


import math
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
x = a1 * (k1 - 1) + a2 * (k2 - 1)
if n - x <= 0:
	S = 0
else:
	S = n - x
if k1 <= k2:
	if n <= a1 * k1:
		y = math.floor(n / k1)
	else:
		y = a1 + math.floor((n - a1 * k1) / k2)
elif n <= a2 * k2:
	y = math.floor(n / k2)
else:
	y = a2 + math.floor((n - a2 * k2) / k1)
print(S, end=' ')
print(y)


import sys
input = sys.stdin.readline
out = sys.stdout

def main():
	a1 = int(input())
	a2 = int(input())
	k1 = int(input())
	k2 = int(input())
	n = int(input())
	min_ = a1 * (k1 - 1) + a2 * (k2 - 1)
	ans_min = n - min_ if min_ < n else 0
	ans_max = 0
	if k1 <= k2:
		while a1 != 0 and n >= k1:
			ans_max += 1
			a1 -= 1
			n -= k1
		if n > 0:
			while a2 != 0 and n >= k2:
				ans_max += 1
				a2 -= 1
				n -= k2
	else:
		while a2 != 0 and n >= k2:
			ans_max += 1
			a2 -= 1
			n -= k2
		if n > 0:
			while a1 != 0 and n >= k1:
				ans_max += 1
				a1 -= 1
				n -= k1
	print(ans_min, ans_max)
main()


a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
f = e - a * (c - 1) - b * (d - 1)
if f < 0:
	f = 0
if c > d:
	g = d
	h = b
	j = c
else:
	g = c
	h = a
	j = d
if e < g * h:
	i = int(e / g)
else:
	i = h + int((e - h * g) / j)
print(f)
print(i)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
minn = n - a1 * (k1 - 1) - a2 * (k2 - 1)
if minn < 0:
	minn = 0
maxx = 0
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
maxx = min(n // k1, a1)
n -= maxx * k1
maxx += min(n // k2, a2)
print(minn, maxx)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
f = c - 1
g = d - 1
h = a * f + b * g
j = e - h
if j > 0:
	if j > a + b:
		y = a + b
	else:
		y = j
else:
	y = 0
f = g = h = i = j = 0
if c < d:
	f = min(e // c, a)
	g = e - f * c
	if f == a:
		h = min(g // d, b)
		i = g - h * d
		z = h + f
	else:
		z = f
elif d < c:
	f = min(e // d, b)
	g = e - f * d
	if f == b:
		h = min(g // c, a)
		i = g - h * c
		z = h + f
	else:
		z = f
elif c == d:
	f = min(e // c, a + b)
	z = f
print(y, z)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
cmin = 0
nremmin = n - a1 * (k1 - 1) - a2 * (k2 - 1)
cmin += nremmin if nremmin > 0 else 0
cmax = 0
if k1 < k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
cmax += min(a2, n // k2)
nrem = n - cmax * k2
if nrem > 0:
	cmax += min(a1, nrem // k1)
print(cmin, cmax)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
l = []
c = a1 * (k1 - 1) + a2 * (k2 - 1)
if c >= n:
	l.append(0)
else:
	l.append(n - c)
if k1 > k2:
	p = k1
	k1 = k2
	k2 = p
	p = a1
	a1 = a2
	a2 = p
c = 0
r = 1
while r > 0:
	if n - k1 >= 0 and a1 - 1 >= 0:
		n = n - k1
		a1 = a1 - 1
		c = c + 1
	elif n - k2 >= 0 and a2 - 1 >= 0:
		n = n - k2
		a2 = a2 - 1
		c = c + 1
	else:
		r = -1
l.append(c)
print(*l)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 < k2:
	pass
else:
	(a1, a2, k1, k2) = (a2, a1, k2, k1)
need_one = k1 * a1
used_one = min(need_one, n)
used_one -= used_one % k1
need_two = (k2 - 1) * a2 + (k1 - 1) * a1
ost = max(n - need_two, 0)
mx = used_one // k1 + (n - used_one) // k2
mn = min(ost, a2 + a1)
print(mn, mx)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
rest = 0
playerOut = 0
firstTeam = k1 * a1
secondeTeam = k2 * a2
minmumPlayer = firstTeam - a1 + (secondeTeam - a2)
minmum = n - minmumPlayer
if minmum < 0:
	minmum = 0
elif minmum > a1 + a2:
	minmum = a1 + a2
if k1 <= k2:
	if n >= firstTeam:
		rest = n - firstTeam
		playerOut = a1
	elif n < firstTeam and n >= a1:
		playerOut = (n - n % k1) / k1
if rest >= k2:
	out = (rest - rest % k2) / k2
	rest = 0
	if out < a2:
		playerOut += out
	else:
		playerOut += a2
if k2 < k1:
	if n >= secondeTeam:
		rest = n - secondeTeam
		playerOut = a2
	elif n < secondeTeam and n >= a2:
		playerOut = (n - n % k2) / k2
	if rest >= k1:
		out = (rest - rest % k1) / k1
		if out < a1:
			playerOut += out
		else:
			playerOut += a1
print(minmum, int(playerOut))


import sys
a1 = int(sys.stdin.readline().strip())
a2 = int(sys.stdin.readline().strip())
k1 = int(sys.stdin.readline().strip())
k2 = int(sys.stdin.readline().strip())
n1 = int(sys.stdin.readline().strip())
n2 = n1
x = 0
y = 0
if k2 < k1:
	(a1, a2, k1, k2) = (a2, a1, k2, k1)
if a1 * k1 < n2:
	y = y + a1
	n2 = n2 - a1 * k1
else:
	y = y + n2 // k1
	n2 = n2 - k1 * (n2 // k1)
y = y + min(n2 // k2, a2)
n1 = n1 - a1 * (k1 - 1) - a2 * (k2 - 1)
if n1 > 0:
	x = n1
print(str(x) + ' ' + str(y))


def main():
	a1 = int(input())
	a2 = int(input())
	k1 = int(input())
	k2 = int(input())
	yellow = int(input())
	yellow2 = yellow
	if k1 < k2:
		a_min = a1
		k_min = k1
		a_max = a2
		k_max = k2
	else:
		a_min = a2
		k_min = k2
		a_max = a1
		k_max = k1
	max_thrown = 0
	for _ in range(a_min):
		if yellow >= k_min:
			max_thrown += 1
			yellow -= k_min
	for _ in range(a_max):
		if yellow >= k_max:
			max_thrown += 1
			yellow -= k_max
	max_thrown = min(max_thrown, a1 + a2)
	yellow2 -= a_min * (k_min - 1) + a_max * (k_max - 1)
	min_thrown = 0
	if yellow2 > 0:
		min_thrown = min(yellow2, a1 + a2)
	print(min_thrown, max_thrown)
main()


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
cnt = a1 * (k1 - 1) + a2 * (k2 - 1)
if n == 1 and (k1 == 1 or k2 == 1):
	print(1)
elif cnt < 0 or n - cnt <= 0:
	print(0)
else:
	print(n - cnt)
if n < a1 * k1:
	print(int(n / k1))
else:
	print(int(a1 + (n - a1 * k1) / k2))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
pla = plb = 0
n1 = n
if k1 <= k2:
	pla = min(n // k1, a1)
	n -= pla * k1
	pla += min(n // k2, a2)
else:
	pla = min(n // k2, a2)
	n -= pla * k2
	pla += min(n // k1, a1)
n = n1
lis = [k1] * a1 + [k2] * a2
lis.sort(reverse=True)
while n > 0:
	t = 0
	for i in range(len(lis)):
		if lis[i] > 1:
			lis[i] -= 1
			n -= 1
			t = 1
		if n == 0:
			break
	if t == 0:
		break
c = lis.count(1)
plb = min(c, n)
print(plb, pla)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
minimum = None
maximum = None
if n <= (k1 - 1) * a1 + (k2 - 1) * a2:
	minimum = 0
else:
	minimum = n - (k1 - 1) * a1 - (k2 - 1) * a2
if k1 <= k2:
	if n <= a1 * k1:
		maximum = n // k1
	else:
		maximum = a1 + (n - a1 * k1) // k2
elif n <= a2 * k2:
	maximum = n // k2
else:
	maximum = a2 + (n - a2 * k2) // k1
print(minimum, maximum)


(a1, a2, k1, k2, n) = [int(input()) for i in range(5)]
(min, max) = (0, 0)
(x, y) = (0, 0)
n1 = n
n2 = n
max1 = max
x = n // k1
if x > a1:
	max += a1
else:
	max += x
y = n1 // k2
if y > a2:
	max1 += a2
else:
	max1 += y
n -= k1 * a1
n1 -= k2 * a2
if n > 0:
	x = n // k2
	if x > a2:
		max += a2
	else:
		max += x
if n1 > 0:
	y = n1 // k1
	if y > a1:
		max1 += a1
	else:
		max1 += y
n2 -= k2 * a2 + k1 * a1 - a2 - a1
if n2 > 0:
	if n2 >= a2 + a1:
		min = a2 + a1
	else:
		min = n2
print(min, max1) if max1 > max else print(min, max)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
kg = None
ks = None
pg = None
ps = None
if k1 >= k2:
	kg = k1
	pg = a1
	ks = k2
	ps = a2
else:
	kg = k2
	pg = a2
	ks = k1
	ps = a1
tolerate = (kg - 1) * pg + (ks - 1) * ps
mini = 0
n_tmp = n
while n_tmp > tolerate:
	mini += 1
	n_tmp -= 1
maxi = 0
n_tmp = n
while n_tmp >= ks and ps > 0:
	n_tmp -= ks
	maxi += 1
	ps -= 1
while n_tmp >= kg and pg > 0:
	n_tmp -= kg
	maxi += 1
	pg -= 1
print(mini, maxi)


a = int(input())
b = int(input())
p = int(input())
q = int(input())
n = int(input())
if n <= a * (p - 1) + b * (q - 1):
	t = 0
else:
	t = n - a * (p - 1) - b * (q - 1)
if p < q:
	if n <= a * p:
		y = n // p
	else:
		y = a + (n - a * p) // q
elif p > q:
	if n <= b * q:
		y = n // q
	else:
		y = b + (n - b * q) // p
else:
	y = n // p
print(t, y)


(a1, a2, y1, y2, n) = (int(input()), int(input()), int(input()), int(input()), int(input()))
k = a1 * (y1 - 1) + a2 * (y2 - 1)
ans1 = max(0, n - k)
if y1 > y2:
	(y1, y2) = (y2, y1)
	(a1, a2) = (a2, a1)
ans2 = min(a1, n // y1)
n = n - min(n, a1 * y1)
ans2 += min(a2, n // y2)
print(ans1, ans2)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
m1 = n - (k1 - 1) * a1 - (k2 - 1) * a2
if m1 < 0:
	m1 = 0
m2 = 0
if a1 * k1 + a2 * k2 <= n:
	m2 = a1 + a2
elif k1 <= k2:
	if n // k1 <= a1:
		m2 = n // k1
	else:
		m2 = m2 + a1
		n = n - a1 * k1
		m2 = m2 + min(a2, n // k2)
elif k2 < k1:
	if n // k2 <= a2:
		m2 = n // k2
	else:
		m2 = m2 + a2
		n = n - a2 * k2
		m2 = m2 + min(a1, n // k1)
print(m1, end=' ')
print(m2)


a = int(input())
b = int(input())
y1 = int(input())
y2 = int(input())
total = int(input())
total1 = total
mi = min(y1, y2)
ma = max(y1, y2)
if mi == y1:
	q = a
	w = b
else:
	q = b
	w = a
temp = (mi - 1) * q + (ma - 1) * w
if temp >= total:
	minimum = 0
if temp < total:
	minimum = total - temp
out = 0
x = total // mi
if x >= q:
	out += q
	total1 = total1 - q * mi
	y = total1 // ma
	out += y
else:
	out = x
print(minimum, out)


import sys

def rint():
	return map(int, sys.stdin.readline().split())
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 < k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
n_ori = n
tmp = a1 * (k1 - 1) + a2 * (k2 - 1)
n -= tmp
min_v = max(0, min(a1 + a2, n))
n = n_ori
p = n // k2
if a2 < p:
	p = a2
	n -= p * k2
else:
	n -= p * k2
if n > 0:
	tmp = n // k1
	if tmp > a1:
		tmp = a1
	p += tmp
max_v = p
print(min_v, max_v)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
x = 0
y = 0
f = (c - 1) * a + (d - 1) * b
g = e - f
if g <= 0:
	x = 0
elif g > a + b:
	x = a + b
else:
	x = g
if c <= d:
	m = e // c
	if m > a:
		y = a
		e = e - a * c
	else:
		y = m
		e = e - m * c
	if e >= d:
		n = e // d
		if n > b:
			y = y + b
		else:
			y = y + n
else:
	m = e // d
	if m > b:
		y = b
		e = e - b * d
	else:
		y = m
		e = e - m * d
	if e >= c:
		n = e // c
		if n > a:
			y = y + a
		else:
			y = y + n
print(x, end=' ')
print(y)


def main():
	t1 = int(input())
	t2 = int(input())
	y1 = int(input())
	y2 = int(input())
	total = int(input())
	maxn = t1 * y1 + t2 * y2
	minn = t1 * (y1 - 1) + t2 * (y2 - 1)
	if total > maxn:
		minval = t1 + t2
		maxval = t1 + t2
	else:
		if total <= minn:
			minval = 0
		else:
			temp = total - minn
			minval = min(temp, t1 + t2)
		if y1 <= y2:
			temp = total // y1
			if temp <= t1:
				maxval = temp
			else:
				maxval = t1
				total -= t1 * y1
				temp = total // y2
				if temp <= t2:
					maxval += temp
				else:
					maxval += t2
		else:
			temp = total // y2
			if temp <= t2:
				maxval = temp
			else:
				maxval = t2
				total -= t2 * y2
				temp = total // y1
				if temp <= t1:
					maxval += temp
				else:
					maxval += t1
	print(minval, maxval)
main()


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
max = 0
n1 = n
n2 = n
if k1 > k2:
	x2 = n2 // k2
	if x2 > a2:
		max += a2
		n2 = n2 - a2 * k2
	else:
		max += x2
		n2 = n2 - a2 * k2
	if n2 > 0:
		x1 = n2 // k1
		if x1 > a1:
			max += a1
			n2 = n2 - a1 * k1
		else:
			max += x1
			n2 = n2 - a1 * k1
else:
	x1 = n1 // k1
	if x1 > a1:
		max += a1
		n1 = n1 - a1 * k1
	else:
		max += x1
		n1 = n1 - a1 * k1
	if n1 > 0:
		x2 = n1 // k2
		if x2 > a2:
			max += a2
			n1 = n1 - a2 * k2
		else:
			max += x2
			n1 = n1 - a2 * k2
r = (k1 - 1) * a1 + (k2 - 1) * a2
if r > n:
	min = 0
else:
	min = n - r
print(min, end=' ')
print(max)


a = int(input())
b = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
A = a * k1
B = b * k2
tmin = max(0, n - (k1 - 1) * a - (k2 - 1) * b)
tmax = -1
if n >= A + B:
	tmax = a + b
elif k1 < k2:
	if n <= A:
		tmax = n // k1
	else:
		tmax = a + (n - A) // k2
elif n <= B:
	tmax = n // k2
else:
	tmax = b + (n - B) // k1
print(tmin, tmax)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k2 < k1:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)

def max_value(x, y, w, u, z):
	mx = 0
	c = min(x, z // w)
	mx += c
	z -= c * w
	c = min(y, z // u)
	mx += c
	return mx

def min_value(x, y, w, u, z):
	return max(z - x * (w - 1) - y * (u - 1), 0)
print(min_value(a1, a2, k1, k2, n), max_value(a1, a2, k1, k2, n))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mi = 0
ma = 0
if k1 < k2:
	lowA = a1
	lowK = k1
	highA = a2
	highK = k2
else:
	lowA = a2
	lowK = k2
	highA = a1
	highK = k1
nCopy = n
for i in range(lowA):
	nCopy -= lowK
	if nCopy >= 0:
		ma += 1
for i in range(highA):
	nCopy -= highK
	if nCopy >= 0:
		ma += 1
cards = a1 * (k1 - 1) + a2 * (k2 - 1)
mi = max(0, n - cards)
print(mi, ma)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if (k1 - 1) * a1 + (k2 - 1) * a2 >= n:
	mini = 0
else:
	r = n - ((k1 - 1) * a1 + (k2 - 1) * a2)
	mini = r
if k1 > k2:
	if n - a2 * k2 > 0:
		maxm = a2
		n = n - a2 * k2
		if n - a1 * k1 > 0:
			maxm += a1
		else:
			maxm = maxm + n // k1
	else:
		maxm = n // k2
elif n - a1 * k1 > 0:
	maxm = a1
	n = n - a1 * k1
	if n - a2 * k2 > 0:
		maxm += a2
	else:
		maxm = maxm + n // k2
else:
	maxm = n // k1
print(mini, maxm)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
m = n
ans1 = 0
ans2 = 0
if k1 < k2:
	ans1 += min(a1, n // k1)
	n -= ans1 * k1
	ans1 += min(a2, n // k2)
	n = m - (a1 * (k1 - 1) + a2 * (k2 - 1))
	if n <= 0:
		pass
	else:
		ans2 = n
else:
	ans1 += min(a2, n // k2)
	n -= ans1 * k2
	ans1 += min(a1, n // k1)
	n = m - (a1 * (k1 - 1) + a2 * (k2 - 1))
	if n <= 0:
		pass
	else:
		ans2 = n
print(' '.join(map(str, [ans2, ans1])))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
x = a1 * k1
r1 = 0
if n <= x:
	r1 = n // k1
else:
	y = n - x
	y //= k2
	r1 = a1 + y
z = a1 * (k1 - 1) + a2 * (k2 - 1)
z2 = n - z
r2 = 0
if z2 < 0:
	r2 = 0
else:
	r2 = z2
print(r2, r1)


n1 = int(input())
n2 = int(input())
k1 = int(input())
k2 = int(input())
m = int(input())
mn = m - ((k1 - 1) * n1 + (k2 - 1) * n2)
if mn < 0:
	mn = 0
if k1 < k2:
	a = k1
	k1 = k2
	k2 = a
	a = n1
	n1 = n2
	n2 = a
k_n2 = m / k2
k_n2 = int(k_n2)
k_n1 = 0
if k_n2 > n2:
	m = m - n2 * k2
	k_n2 = n2
	k_n1 = m / k1
	k_n1 = int(k_n1)
mx = k_n1 + k_n2
print(mn, mx)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
t = int(input())
aa = 1 * t
l = [k1] * a1
l1 = [k2] * a2
l.extend(l1)
l.sort()
max = 0
for i in range(len(l)):
	t = t - l[i]
	if t >= 0:
		max += 1
x = sum(l) - len(l)
m = 0
if aa <= x:
	print(m, max)
else:
	print(min(len(l), aa - x), max)


import math

def main():
	a1 = int(input())
	a2 = int(input())
	k1 = int(input())
	k2 = int(input())
	n = int(input())
	m = max(0, n - (a1 * (k1 - 1) + a2 * (k2 - 1)))
	m1 = min(a2, n // k2) + min(a1, (n - min(a2, n // k2) * k2) // k1)
	m2 = min(a1, n // k1) + min(a2, (n - min(a1, n // k1) * k1) // k2)
	print(m, max(m2, m1))
main()


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
minicards = (k1 - 1) * a1 + (k2 - 1) * a2
ans = [0, 0]
ans[0] = max(n - minicards, 0)
if k1 > k2:
	ans[1] += min(n // k2, a2)
	n -= min(n // k2, a2) * k2
	ans[1] += min(n // k1, a1)
	n -= min(n // k1, a1) * k1
else:
	ans[1] += min(n // k1, a1)
	n -= min(n // k1, a1) * k1
	ans[1] += min(n // k2, a2)
	n -= min(n // k2, a2) * k2
print(*ans)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
ans_min = 0
ans_max = 0
max_n = n
min_n = n
if min_n <= a1 * (k1 - 1) + a2 * (k2 - 1):
	ans_min = 0
else:
	count = 0
	min_n = min_n - a1 * (k1 - 1) - a2 * (k2 - 1)
	total = a1 + a2
	while min_n > 0 and total > 0:
		min_n = min_n - 1
		total = total - 1
		count = count + 1
	ans_min = count
if max_n >= a1 * k1 + a2 * k2:
	ans_max = a1 + a2
else:
	max_cards = max(k1, k2)
	min_cards = min(k1, k2)
	if max_cards == k1:
		max_team = a1
		min_team = a2
	else:
		max_team = a2
		min_team = a1
	count = 0
	while min_team > 0 and max_n > 0 and (max_n >= min_cards):
		max_n = max_n - min_cards
		min_team = min_team - 1
		count = count + 1
	while max_team > 0 and max_n > 0 and (max_n >= max_cards):
		max_n = max_n - max_cards
		max_team = max_team - 1
		count = count + 1
	ans_max = count
print(ans_min, end=' ')
print(ans_max)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
minn = 0
maxx = 0
minn = max(n - (a1 * (k1 - 1) + a2 * (k2 - 1)), 0)
if k1 < k2:
	while True:
		if a1 * k1 <= n:
			n -= a1 * k1
			maxx += a1
			break
		else:
			a1 -= 1
			if a1 <= 0:
				break
	while True:
		if a2 * k2 <= n:
			n -= a2 * k2
			maxx += a2
			break
		else:
			a2 -= 1
			if a2 <= 0:
				break
else:
	while True:
		if a2 * k2 <= n:
			n -= a2 * k2
			maxx += a2
			break
		else:
			a2 -= 1
			if a2 <= 0:
				break
	while True:
		if a1 * k1 <= n:
			n -= a1 * k1
			maxx += a1
			break
		else:
			a1 -= 1
			if a1 <= 0:
				break
print(minn, maxx)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
m = 0
ma = 0
if k1 - 1 and k2 - 1:
	n1 = (k1 - 1) * a1
	n2 = (k2 - 1) * a2
	if n <= n1 + n2:
		m = 0
	else:
		m = n - (n1 + n2)
elif k1 - 1:
	n1 = (k1 - 1) * a1
	if n <= n1:
		m = 0
	else:
		m = n - n1
else:
	n2 = (k2 - 1) * a2
	if n <= n2:
		m = 0
	else:
		m = n - n2
if k1 > k2:
	n2 = n // k2
	if n2 > a2:
		n2 = n - a2 * k2
		ma += a2
		ma += n2 // k1
	else:
		ma = n2
else:
	n1 = n // k1
	if n1 > a1:
		n1 = n - a1 * k1
		ma += a1
		ma += n1 // k2
	else:
		ma = n1
print(m, ma)


import sys, collections
a1 = int(sys.stdin.readline())
a2 = int(sys.stdin.readline())
k1 = int(sys.stdin.readline())
k2 = int(sys.stdin.readline())
y = int(sys.stdin.readline())
mild = y
mild -= a1 * (k1 - 1) + a2 * (k2 - 1)
min_p = 0
max_p1 = 0
max_p2 = 0
if mild > 0:
	min_p = mild
hot1 = y
if hot1 >= a1 * k1:
	max_p1 = a1
	hot1 -= a1 * k1
	if hot1 > 0:
		max_p1 += hot1 // k2
else:
	max_p1 = hot1 // k1
hot2 = y
if hot2 >= a2 * k2:
	max_p2 = a2
	hot2 -= a2 * k2
	if hot2 > 0:
		max_p2 += hot2 // k1
else:
	max_p2 = hot2 // k2
print(min_p, max(max_p1, max_p2))


import sys
import queue

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
d = n // min(k1, k2)
n1 = n
if min(k1, k2) == k1:
	maxi = min(a1, d)
	n1 = n1 - maxi * k1
else:
	maxi = min(a2, d)
	n1 = n1 - maxi * k2
maxi = maxi + n1 // max(k1, k2)
d = (k1 - 1) * a1 + (k2 - 1) * a2
if n <= d:
	mini = 0
else:
	n = n - d
	if n > a1 + a2:
		mini = a1 + a2
	else:
		mini = n
print(mini, maxi)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
maxk = 0
kol = 0
minn = n - (a1 * k1 - a1 + a2 * k2 - a2)
if minn < 0:
	minn = 0
if k1 < k2:
	if k1 * a1 >= n:
		kol = n // k1
		if kol > a1:
			kol = a1
	else:
		kol += a1
		n = n - k1 * a1
		kol += n // k2
elif k2 * a2 >= n:
	kol = n // k2
	if kol > a2:
		kol = a2
else:
	kol += a2
	n = n - k2 * a2
	kol += n // k1
print(str(minn) + ' ' + str(kol))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mx = 0
if k1 > k2:
	(a1, a2) = (a2, a1)
	(k1, k2) = (k2, k1)
mxf = n // k1
mx = mxf
if mxf > a1:
	mx = a1
	nn = n - a1 * k1
	mx += nn // k2
bnd = a1 * (k1 - 1) + a2 * (k2 - 1)
mn = 0
if n > bnd:
	mn = n - bnd
else:
	mn = 0
print(mn, mx)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if n <= a1 * (k1 - 1) + a2 * (k2 - 1):
	print(0, end=' ')
elif n > a1 * (k1 - 1) + a2 * (k2 - 1):
	print(min(n - a1 * (k1 - 1) - a2 * (k2 - 1), a1 + a2), end=' ')
if k1 <= k2:
	print(min(n // k1, a1) + max(n - min(n // k1, a1) * k1, 0) // k2, end=' ')
elif k2 < k1:
	print(min(n // k2, a2) + max(n - min(n // k2, a2) * k2, 0) // k1, end=' ')


import sys

def main():
	a1 = int(input())
	a2 = int(input())
	k1 = int(input())
	k2 = int(input())
	n = int(input())
	a = n - (k1 - 1) * a1 - (k2 - 1) * a2
	print(max(a, 0), end=' ')
	if k1 > k2:
		(k1, k2) = (k2, k1)
		(a1, a2) = (a2, a1)
	if n > k1 * a1:
		print(a1 + (n - k1 * a1) // k2)
	else:
		print(n // k1)
main()


def solve(a_1, a_2, k_1, k_2, n):
	k_min = min(k_1, k_2)
	a_min = a_1 if k_min == k_1 else a_2
	a_max = a_1 if k_min == k_2 else a_2
	k_max = max(k_1, k_2)
	q_min = min(max(0, n - (a_1 * (k_1 - 1) + a_2 * (k_2 - 1))), a_1 + a_2)
	q_max = min(a_min, n // k_min) + max(0, min(a_max, (n - a_min * k_min) // k_max))
	return (q_min, q_max)
a_1 = int(input())
a_2 = int(input())
k_1 = int(input())
k_2 = int(input())
n = int(input())
res = solve(a_1, a_2, k_1, k_2, n)
print(res[0], res[1])


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
temp = a1 * (k1 - 1) + a2 * (k2 - 1)
ans2 = max(0, n - temp)
ans1 = 0
if k1 <= k2:
	while n > 0 and a2 > 0:
		ans1 = ans1 + 1
		if a1 > 0 and n - k1 >= 0:
			n = n - k1
			a1 = a1 - 1
		elif a2 > 0 and n - k2 >= 0:
			n = n - k2
			a2 = a2 - 1
		else:
			ans1 = ans1 - 1
			break
else:
	while n > 0 and a1 > 0:
		ans1 = ans1 + 1
		if a2 > 0 and n - k2 >= 0:
			n = n - k2
			a2 = a2 - 1
		elif a1 > 0 and n - k1 >= 0:
			n = n - k1
			a1 = a1 - 1
		else:
			ans1 = ans1 - 1
			break
print(ans2, ans1)


import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def revn(n):
	m = 0
	while n > 0:
		m = m * 10 + n % 10
		n = n // 10
	return m
a1 = ii()
a2 = ii()
k1 = ii()
k2 = ii()
n = ii()
if k1 > k2:
	print(max(0, n - a1 * (k1 - 1) - a2 * (k2 - 1)), min(n, a2 * k2) // k2 + max(0, n - a2 * k2) // k1)
else:
	print(max(0, n - a1 * (k1 - 1) - a2 * (k2 - 1)), min(n, a1 * k1) // k1 + max(0, n - a1 * k1) // k2)


num1 = int(input())
num2 = int(input())
per1 = int(input())
per2 = int(input())
card = int(input())
total = num1 + num2
if per1 <= per2:
	min_per = per1
	max_per = per2
	min_num = num1
	max_num = num2
else:
	min_per = per2
	max_per = per1
	min_num = num2
	max_num = num1
total = num1 + num2
old = card
old_num = 0
old_per = min_per
while True:
	if old_num == min_num:
		old_per = max_per
	old -= old_per
	old_num += 1
	if old == 0:
		break
	if old < 0:
		old_num -= 1
		break
result2 = old_num
a1 = card - ((per1 - 1) * num1 + (per2 - 1) * num2)
if a1 <= 0:
	result1 = 0
else:
	result1 = a1
if total < result1:
	result1 = total
print(result1, result2)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
n_min = a1 * (k1 - 1) + a2 * (k2 - 1)
ost = n - n_min
if ost <= 0:
	print(0, end=' ')
else:
	print(min(a1 + a2, ost), end=' ')
if k1 > k2:
	(k2, k1) = (k1, k2)
	(a1, a2) = (a2, a1)
d = n // k1
n_1 = min(a1, d)
n -= n_1 * k1
n_2 = min(a2, n // k2)
print(n_1 + n_2)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if n >= a1 * k1 + a2 * k2:
	print(str(a1 + a2) + ' ' + str(a1 + a2))
else:
	count = 0
	x = max(0, a1 + a2 - (a1 * k1 + a2 * k2 - n))
	if k1 < k2:
		if n // k1 >= a1:
			count += a1
			n = n - a1 * k1
			count += n // k2
		else:
			count += n // k1
	elif n // k2 >= a2:
		count += a2
		n = n - a2 * k2
		count += n // k1
	else:
		count += n // k2
	print(str(x) + ' ' + str(count))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
m = n - (a1 * (k1 - 1) + a2 * (k2 - 1))
if m < 0:
	m = 0
if a1 * k1 >= n:
	ma = n // k1
else:
	ma = a1 + (n - a1 * k1) // k2
print(m, ma)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
x = a1 * (k1 - 1) + a2 * (k2 - 1)
if x >= n:
	min1 = 0
else:
	min1 = n - x
if k1 < k2:
	d1 = n // k1
	if d1 >= a1:
		d1 = a1
	d2 = (n - d1 * k1) // k2
else:
	d2 = n // k2
	if d2 >= a2:
		d2 = a2
	d1 = (n - d2 * k2) // k1
if d1 >= a1:
	d1 = a1
if d2 >= a2:
	d2 = a2
print(min1, d1 + d2)


import sys
command1 = int(input())
command2 = int(input())
k1 = int(input())
k2 = int(input())
card = int(input())
min = 0
max = 0
mans = command1 + command2
i = 0
g = 0
d1 = k1
d2 = k2
c = 0
v = 0
m = 0
if command1 * k1 + k2 * command2 == card:
	min = mans
	max = mans
	print(min, max)
	sys.exit()

def maxcards(command1, card, command2, i, g):
	if k1 < k2 or k1 == k2:
		while command1 > 0 and card > 0:
			card -= k1
			if card >= 0:
				command1 -= 1
				i += 1
			else:
				break
		while command2 > 0 and card > 0:
			card -= k2
			if card >= 0:
				command2 -= 1
				g += 1
			else:
				break
	elif k2 < k1:
		while command2 > 0 and card > 0:
			card -= k2
			if card >= 0:
				command2 -= 1
				i += 1
			else:
				break
		while command1 > 0 and card > 0:
			card -= k1
			if card >= 0:
				command1 -= 1
				g += 1
			else:
				break
	return i + g
m = maxcards(command1, card, command2, i, g)
c = card - ((k1 - 1) * command1 + (k2 - 1) * command2)
if c < 0:
	c = 0
print(c, m)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k2 == max(k1, k2):
	b = 2
else:
	b = 1
if n > a1 * (k1 - 1) + a2 * (k2 - 1):
	print(n - a1 * (k1 - 1) - a2 * (k2 - 1), end=' ')
else:
	print(0, end=' ')
if b == 1:
	if n > a2 * k2:
		print(a2 + (n - a2 * k2) // k1, end='')
	else:
		print(n // k2, end=' ')
elif n > a1 * k1:
	print(a1 + (n - a1 * k1) // k2, end='')
else:
	print(n // k1, end=' ')


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
x = a1 * k1 + a2 * k2 - (a1 + a2)
min = 0
max = 0
for i in range(n - x):
	min += 1
if k1 < k2:
	total = a1 * k1
	if n > total:
		max += a1
		n -= total
		total2 = a2 * k2
		if n > total2:
			max += a2
		else:
			max += n // k2
	else:
		max += n // k1
elif k2 < k1:
	total = a2 * k2
	if n > total:
		max += a2
		n -= total
		total2 = a1 * k1
		if n > total2:
			max += a1
		else:
			max += n // k1
	else:
		max += n // k2
else:
	max += n // k1
print('{} {}'.format(min, max))


def max(a1, a2, k1, k2, n):
	count = 0
	if k1 < k2:
		first = a1
		d = k1
	else:
		first = a2
		d = k2
	second = a1 + a2 - first
	d2 = k1 + k2 - d
	while n > 0 and first > 0:
		n -= d
		count += 1
		first -= 1
	while n > 0 and second > 0:
		n -= d2
		count += 1
		second -= 1
	if n < 0:
		print(count - 1)
	else:
		print(count)

def min(a1, a2, k1, k2, n):
	fell = a1 * (k1 - 1) + a2 * (k2 - 1)
	if n > fell:
		print(n - fell, end=' ')
	else:
		print(0, end=' ')
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
min(a1, a2, k1, k2, n)
max(a1, a2, k1, k2, n)


def main():
	a1 = int(input())
	a2 = int(input())
	k1 = int(input())
	k2 = int(input())
	n = int(input())
	t = a1 * (k1 - 1) + a2 * (k2 - 1)
	r = max(0, n - t)
	if k1 < k2:
		z = min(n // k1, a1)
		a1 -= z
		n -= z * k1
	else:
		z = min(n // k2, a2)
		a2 -= z
		n -= z * k2
	z1 = min(n // k1, a1)
	a1 -= z1
	n -= z1 * k1
	z2 = min(n // k2, a2)
	a1 -= z2
	n -= z2 * k2
	print(r, z + z1 + z2)
main()


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
x = a1 * (k1 - 1) + a2 * (k2 - 1)
mini = n - x
if mini <= 0:
	mini = 0
y = min(k1, k2)
mc = 0
t = 0
while t <= n:
	if y == k1:
		a1 -= 1
		t += y
		mc += 1
		if a1 == 0:
			break
	else:
		a2 -= 1
		t += y
		mc += 1
		if a2 == 0:
			break
rem = n - t
if rem < 0:
	mc -= 1
	rem = n - n // y * y
if rem > 0:
	mc += rem // max(k1, k2)
print(mini, mc)


def solve():
	a1 = int(input())
	a2 = int(input())
	k1 = int(input())
	k2 = int(input())
	n = int(input())
	minimum = n - (k2 - 1) * a2 - (k1 - 1) * a1 if n - (k2 - 1) * a2 - (k1 - 1) * a1 > 0 else 0
	smallest = min(k1, k2)
	team = 1 if k1 == smallest else 2
	if team == 1:
		maximum = n // k1 if n // k1 <= a1 else a1
		if n <= a1 * k1:
			print(minimum, maximum)
			return
		else:
			n -= a1 * k1
			print(minimum, n // k2 + maximum)
			return
	else:
		maximum = n // k2 if n // k2 <= a2 else a2
		if n <= a2 * k2:
			print(minimum, maximum)
			return
		else:
			n -= a2 * k2
			print(minimum, n // k1 + maximum)
			return
solve()


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mx = 0
mn = 0
s = (k1 - 1) * a1 + (k2 - 1) * a2
if s < n and s >= 0:
	mn = n - s
if k1 < k2:
	if n <= a1 * k1:
		mx = n // k1
	else:
		z = n - a1 * k1
		mx = a1 + z // k2
elif n <= a2 * k2:
	mx = n // k2
else:
	z = n - a2 * k2
	mx = a2 + z // k1
print(mn, mx)


from copy import copy

def main():
	t_s = [[None, None], [None, None]]
	t_s[0][0] = int(input())
	t_s[1][0] = int(input())
	t_s[0][1] = int(input())
	t_s[1][1] = int(input())
	t_s = sorted(t_s, key=lambda x: x[1])
	n_cards = int(input())
	(max_, min_) = (0, 0)
	cards = n_cards
	team = t_s[0][0]
	while team > 0 and t_s[0][1] <= cards:
		max_ += 1
		cards -= t_s[0][1]
		team -= 1
	team = t_s[1][0]
	while team > 0 and t_s[1][1] <= cards:
		max_ += 1
		cards -= t_s[1][1]
		team -= 1
	total_cards_needed = t_s[0][0] * t_s[0][1] + t_s[1][0] * t_s[1][1]
	min_ = n_cards - total_cards_needed + (t_s[0][0] + t_s[1][0]) if total_cards_needed - (t_s[0][0] + t_s[1][0]) < n_cards else 0
	print(min_, max_)
main()


from collections import OrderedDict

def send_off_team(k, p, cs):
	return min(cs // k, p)
p1 = int(input())
p2 = int(input())
k1 = int(input())
k2 = int(input())
cs = int(input())
cs_left = cs - ((k1 - 1) * p1 + (k2 - 1) * p2)
mins = max(min(p1 + p2, cs_left), 0)
p1_sent = send_off_team(k1, p1, cs)
cs_left = cs - p1_sent * k1
p2_sent = send_off_team(k2, p2, cs_left)
maxs_k1_k2 = p1_sent + p2_sent
p1_sent = send_off_team(k2, p2, cs)
cs_left = cs - p1_sent * k2
p2_sent = send_off_team(k1, p1, cs_left)
maxs_k2_k1 = p1_sent + p2_sent
maxs = max(maxs_k2_k1, maxs_k1_k2)
print(mins, maxs)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mn = a1 * k1 + a2 * k2 - (a1 + a2)
mnum = min(a1 + a2, max(n - mn, 0))
c = 0
if k1 > k2:
	ok = k1
	oa = a1
	k1 = k2
	a1 = a2
	k2 = ok
	a2 = oa
mx = a1 * k1
if n > mx:
	n -= mx
	c += mx // k1
else:
	c += n // k1
	mx = 0
if mx > 0:
	c += min(n // k2, a2)
print(mnum, c)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
r = a1 * (k1 - 1) + a2 * (k2 - 1)
if r >= n:
	low = 0
else:
	low = n - r
mas = [k2] * a2 + [k1] * a1 if k1 > k2 else [k1] * a1 + [k2] * a2
i = 0
high = 0
while n > 0:
	mas[i] -= 1
	n -= 1
	if mas[i] == 0:
		i += 1
print(low, i)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
c = int(input())
(mina, max) = (0, 0)
c1 = c
if c1 >= a1 * k1:
	c1 -= a1 * k1
	max += a1
else:
	max += int(c1 / k1)
	c1 -= int(c1 / k1) * k1
if c1 > 0:
	max += int(c1 / k2)
c2 = c
temp = 0
if c2 >= a2 * (k2 - 1):
	c2 -= a2 * (k2 - 1)
else:
	c2 = 0
if c2 > 0:
	if c2 >= a1 * (k1 - 1):
		c2 -= a1 * (k1 - 1)
	else:
		c2 = 0
if c2 > 0:
	mina = c2
print(mina, max)


def func(aa1, aa2, kk1, kk2, nn):
	if nn <= aa1 * (kk1 - 1) + aa2 * (kk2 - 1):
		print(0)
	elif nn < aa1 * kk1 + aa2 * kk2:
		print(nn - aa1 * (kk1 - 1) - aa2 * (kk2 - 1))
	else:
		print(aa1 + aa2)
	if nn <= aa1 * kk1:
		print(nn // kk1)
	elif nn <= aa1 * kk1 + aa2 * kk2:
		print((nn - aa1 * kk1) // kk2 + aa1)
	else:
		print(aa1 + aa2)
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 <= k2:
	func(a1, a2, k1, k2, n)
else:
	func(a2, a1, k2, k1, n)


a = int(input())
b = int(input())
k1 = int(input())
k2 = int(input())
t = int(input())
r = t - a * (k1 - 1) - b * (k2 - 1)
if r < 0:
	r = 0
if k1 < k2:
	(k1, k2) = (k2, k1)
	(a, b) = (b, a)
if b * k2 < t:
	t = t - b * k2
	if a * k1 < t:
		l = a + b
	else:
		l = b + int(t / k1)
else:
	l = int(t / k2)
print(r, l)


from math import *
from sys import *
from collections import defaultdict
import os, sys
from io import IOBase, BytesIO
M = 10 ** 9 + 7

def pow(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res *= a
		a *= a
		b >>= 1
	return res

def powmod(a, b, m):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a *= a
		b >>= 1
	return res

def inv(a, m):
	return powmod(a, m - 2, m)

def factor(n):
	potentional_p = 3
	itog_list = {}
	if n % 2 == 0:
		itog_list[2] = 0
	while n % 2 == 0:
		n = n // 2
		itog_list[2] += 1
	while n - 1:
		if potentional_p > n ** 0.5:
			if n in itog_list:
				itog_list[n] += 1
			else:
				itog_list[n] = 1
			return itog_list
		while n % potentional_p == 0:
			n = n // potentional_p
			if potentional_p in itog_list:
				itog_list[potentional_p] += 1
			else:
				itog_list[potentional_p] = 1
		potentional_p += 2
	return itog_list

def main():
	a1 = int(input())
	a2 = int(input())
	k1 = int(input())
	k2 = int(input())
	n = int(input())
	mn = -1
	if a1 * (k1 - 1) + a2 * (k2 - 1) >= n:
		mn = 0
	else:
		mn = abs(a1 * (k1 - 1) + a2 * (k2 - 1) - n)
	mx = 0
	if k1 > k2:
		(k1, k2) = (k2, k1)
		(a1, a2) = (a2, a1)
	if 1 == 1:
		val = n // k1
		if val >= a1:
			mx += a1
			n -= a1 * k1
		else:
			mx += val
			n -= val * k1
		val = n // k2
		if val >= a2:
			mx += a2
			n -= a2 * k2
		else:
			mx += val
			n -= val * k2
	print(mn, mx)
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 > k2:
	(a1, a2) = (a2, a1)
	(k1, k2) = (k2, k1)
r = a1 * (k1 - 1) + a2 * (k2 - 1)
t = max(0, n - r)
if n // k1 <= a1:
	z = n // k1
else:
	z = a1 + (n - a1 * k1) // k2
print(t, end=' ')
print(z)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
a = 0
b = 0
c = n
if k1 < k2:
	if n >= k1 * a1:
		a = a + a1
		n = n - k1 * a1
		if n >= k2 * a2:
			a = a + a2
		else:
			a = a + n // k2
	else:
		a = a + n // k1
elif n >= k2 * a2:
	a = a + a2
	n = n - k2 * a2
	if n >= k1 * a1:
		a = a + a1
	else:
		a = a + n // k1
else:
	a = a + n // k2
b = c - ((k1 - 1) * a1 + (k2 - 1) * a2)
if b >= 0:
	print(b, a)
else:
	print(0, a)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
c = n
an1 = 0
an2 = 0
an3 = 0
an4 = 0
if min(k1, k2) == k1:
	if a1 < n // k1:
		an1 += a1
		if a2 < (n - a1 * k1) // k2:
			an2 += a2
		else:
			an2 = (n - a1 * k1) // k2
	else:
		an1 += n // k1
elif a2 < n // k2:
	an2 += a2
	if a1 < (n - a2 * k2) // k1:
		an1 += a1
	else:
		an1 = (n - a2 * k2) // k1
else:
	an2 += n // k2
n = n - a1 * (k1 - 1) - a2 * (k2 - 1)
if n <= 0:
	mi = 0
else:
	mi = min(a1 + a2, n)
print(mi, an1 + an2)


from math import ceil
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
y = a1 * k1
mxc = 0
if n <= y:
	mxc = n // k1
else:
	mxc = a1 + (n - y) // k2
x = a1 * (k1 - 1) + a2 * (k2 - 1)
mnc = n - x
if mnc <= 0:
	mnc = 0
else:
	mnc = n - x
print(mnc, mxc)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
max_sustain = (k1 - 1) * a1 + (k2 - 1) * a2
min_out = min(a1 + a2, max(n - max_sustain, 0))
if k1 < k2:
	max_out = min(n // k1, a1)
	n -= k1 * max_out
	max_out += min(n // k2, a2)
else:
	max_out = min(n // k2, a2)
	n -= k2 * max_out
	max_out += min(n // k1, a1)
print(min_out, max_out)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
temp = a1 * k1 - a1 + a2 * k2 - a2
if temp >= n:
	print(0, end=' ')
else:
	print(n - temp, end=' ')
if k1 < k2:
	temp = a1 * k1
	if temp <= n:
		print(a1 + (n - temp) // k2)
	else:
		print(n // k1)
else:
	temp = a2 * k2
	if temp <= n:
		print(a2 + (n - temp) // k1)
	else:
		print(n // k2)


def min_cnt(a1, a2, k1, k2, n):
	cnt = 0
	if k1 > k2:
		for i in range(len(a1)):
			if n - (a1[i] - 1) >= 0:
				n -= a1[i] - 1
				a1[i] = 1
			else:
				return cnt
		for i in range(len(a2)):
			if n - (a2[i] - 1) >= 0:
				n -= a2[i] - 1
				a2[i] = 1
			else:
				return cnt
	else:
		for i in range(len(a2)):
			if n - (a2[i] - 1) >= 0:
				n -= a2[i] - 1
				a2[i] = 1
			else:
				return cnt
		for i in range(len(a1)):
			if n - (a1[i] - 1) >= 0:
				n -= a1[i] - 1
				a1[i] = 1
			else:
				return cnt
	for i in a1 + a2:
		if n - i >= 0:
			n -= i
			cnt += 1
		else:
			return cnt
	return cnt

def max_cnt(a1, a2, k1, k2, n):
	cnt = 0
	if k1 < k2:
		for i in range(len(a1)):
			if n - a1[i] >= 0:
				n -= a1[i]
				a1[i] = 0
				cnt += 1
			else:
				return cnt
		for i in range(len(a2)):
			if n - a2[i] >= 0:
				n -= a2[i]
				a2[i] = 0
				cnt += 1
			else:
				return cnt
	else:
		for i in range(len(a2)):
			if n - a2[i] >= 0:
				n -= a2[i]
				a2[i] = 0
				cnt += 1
			else:
				return cnt
		for i in range(len(a1)):
			if n - a1[i] >= 0:
				n -= a1[i]
				a1[i] = 0
				cnt += 1
			else:
				return cnt
	return cnt
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
A1_list = [k1 for _ in range(a1)]
A2_list = [k2 for _ in range(a2)]
result_min = min_cnt(A1_list[:], A2_list[:], k1, k2, n)
result_max = max_cnt(A1_list[:], A2_list[:], k1, k2, n)
print(result_min, result_max)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
nn = n
if n < k1 and n < k2:
	print(0, 0)
	exit()
mx = 0
if k1 < k2:
	(a1, a2, k1, k2) = (a2, a1, k2, k1)
if n >= a2 * k2:
	mx = a2
	n -= a2 * k2
	if n >= a1 * k1:
		mx = a2 + a1
	else:
		mx += n // k1
else:
	mx += n // k2
n = nn
mn = 0
if k1 < k2:
	(a1, a2, k1, k2) = (a2, a1, k2, k1)
n -= a1 * (k1 - 1)
n -= a2 * (k2 - 1)
if n <= 0:
	mn = 0
else:
	mn = n
print(mn, mx)


import sys
from collections import defaultdict as dd
from itertools import permutations as pp
from itertools import combinations as cc
from collections import Counter as ccd
from random import randint as rd
from bisect import bisect_left as bl
from heapq import heappush as hpush
from heapq import heappop as hpop
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
a1 = ri(1)
a2 = ri(1)
k1 = ri(1)
k2 = ri(1)
n = ri(1)
ans2 = 0
ans1 = 0
if k1 < k2:
	temp = n
	for i in range(a1):
		if temp - k1 >= 0:
			ans2 += 1
			temp -= k1
	for i in range(a2):
		if temp - k2 >= 0:
			ans2 += 1
			temp -= k2
	temp = n
	less = 0
	for i in range(a1):
		if temp - (k1 - 1) >= 0:
			less += 1
			temp -= k1 - 1
		else:
			temp = 0
	for i in range(a2):
		if temp - (k2 - 1) >= 0:
			less += 1
			temp -= k2 - 1
		else:
			temp = 0
	ans1 = min(temp, less)
else:
	temp = n
	for i in range(a2):
		if temp - k2 >= 0:
			ans2 += 1
			temp -= k2
	for i in range(a1):
		if temp - k1 >= 0:
			ans2 += 1
			temp -= k1
	temp = n
	less = 0
	for i in range(a2):
		if temp - (k2 - 1) >= 0:
			less += 1
			temp -= k2 - 1
		else:
			temp = 0
	for i in range(a1):
		if temp - (k1 - 1) >= 0:
			less += 1
			temp -= k1 - 1
		else:
			temp = 0
	ans1 = min(temp, less)
print(ans1, ans2)


def max1(a1, c, n, k1, k2, a2, d):
	e = int(n / k1)
	while e > 0 and a1 != 0:
		c = c + 1
		e = e - 1
		a1 = a1 - 1
	n = n - k1 * c
	f = int(n / k2)
	while f > 0 and a2 != 0:
		d = d + 1
		f = f - 1
		a2 = a2 - 1
	return c + d
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
c = 0
d = 0
t = 0
s = a1 * (k1 - 1) + a2 * (k2 - 1)
if s >= n:
	t = 0
else:
	t = n - s
x = max1(a1, c, n, k1, k2, a2, d)
(a1, a2) = (a2, a1)
(k1, k2) = (k2, k1)
y = max1(a1, c, n, k1, k2, a2, d)
print(t, max(x, y))


import sys
from copy import *
from bisect import *
from itertools import permutations as prm, product

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def string(s):
	return ''.join(s)

def fori(n):
	return [fi() for i in range(n)]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < m and (a[i][j] != '.')

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = 1
while t > 0:
	t -= 1
	(a, b, k, l, n) = fori(5)
	maxi = 0
	c = a * (k - 1) + b * (l - 1)
	print(max(0, n - c), end=' ')
	for i in range(a + 1):
		for j in range(b + 1):
			if i * k + j * l <= n:
				maxi = max(maxi, i + j)
	print(maxi)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
full = a1 * (k1 - 1) + a2 * (k2 - 1)
minimum = max(0, n - full)
print(minimum, end=' ')
if k2 < k1:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
max1 = n // k1
if max1 < a1:
	print(max1)
else:
	print(a1 + (n - a1 * k1) // k2)


(a1, a2, k1, k2, n) = [int(input()) for i in range(5)]
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
m = n
m -= a1 * (k1 - 1) + a2 * (k2 - 1)
if m > 0:
	min = m
else:
	min = 0
if a1 < n // k1:
	max = a1 + (n - a1 * k1) // k2
else:
	max = n // k1
print(min, max)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
m = n - a1 * (k1 - 1) - a2 * (k2 - 1)
minn = int(0)
if m <= 0:
	minn = 0
else:
	minn = min(m, a1 + a2)
maxx = int(0)
if k1 > k2:
	b = min(n // k2, a2)
	n -= b * k2
	maxx += b
	maxx += min(n // k1, a1)
else:
	b = min(n // k1, a1)
	n -= b * k1
	maxx += b
	maxx += min(n // k2, a2)
print(minn, maxx)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
maxka = max((k1, a1), (k2, a2))
minka = min((k1, a1), (k2, a2))
maxn = n // minka[0]
if maxn > minka[1]:
	maxn = minka[1] + (n - minka[1] * minka[0]) // maxka[0]
s = a1 * (k1 - 1) + a2 * (k2 - 1)
if s > n:
	minn = 0
elif n - s >= a1 + a2:
	minn = a1 + a2
else:
	minn = n - s
print(minn, maxn)


playerFirst = int(input())
playerSecond = int(input())
yellowFirst = int(input())
yellowSecond = int(input())
totalYellow = int(input())
mini = 0
maxi = playerFirst + playerSecond
margin = (yellowFirst - 1) * playerFirst + (yellowSecond - 1) * playerSecond
if margin > totalYellow:
	mini = 0
else:
	mini = totalYellow - margin
low = min(yellowFirst, yellowSecond)
high = max(yellowFirst, yellowSecond)
if yellowFirst <= yellowSecond:
	corresponding = playerFirst
	nocorresponding = playerSecond
else:
	nocorresponding = playerFirst
	corresponding = playerSecond
if int(totalYellow / low) < corresponding:
	maxi = int(totalYellow / low)
else:
	maxi = int(totalYellow / low)
	extra = int((maxi - corresponding) * low + totalYellow % low)
	other = extra / high
	if other > nocorresponding:
		other = nocorresponding
	maxi = corresponding + other
	maxi = int(maxi)
print(mini, maxi)


(a1, a2, k1, k2, n) = (int(input()) for i in range(5))
if k1 > k2:
	(a1, a2) = (a2, a1)
	(k1, k2) = (k2, k1)
min_cnt = max(0, n - a1 * (k1 - 1) - a2 * (k2 - 1))
max_cnt = min(a1, n // k1)
max_cnt += min(a2, (n - max_cnt * k1) // k2)
print(min_cnt, max_cnt)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
players = a1 + a2
minim = a1 * (k1 - 1) + a2 * (k2 - 1)
min_res = 0
if minim >= n:
	min_res = 0
else:
	min_res = n - minim
min_k = 0
min_a = 0
max_k = 0
max_a = 0
if k1 < k2:
	min_k = k1
	min_a = a1
	max_a = a2
	max_k = k2
else:
	min_k = k2
	min_a = a2
	max_k = k1
	max_a = a1
m1 = min(n // min_k, min_a)
m2 = min((n - m1 * min_k) // max_k, max_a)
print(str(min_res) + ' ' + str(m1 + m2))


def min_cards(a, b, k1, k2, n):
	n = n - min((k2 - 1) * b, n)
	n = n - min((k1 - 1) * a, n)
	return n

def max_cards(a, b, k1, k2, n):
	count = 0
	p = n // k1
	count += min(a, p)
	n -= min(a * k1, p * k1)
	q = n // k2
	count += min(b, q)
	return count
a = int(input())
b = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 > k2:
	t = k1
	k1 = k2
	k2 = t
	t = a
	a = b
	b = t
mini = min_cards(a, b, k1, k2, n)
maxi = max_cards(a, b, k1, k2, n)
print(mini, maxi)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
if a * (c - 1) + b * (d - 1) >= e:
	v = 0
elif a * (c - 1) + b * (d - 1) < e:
	v = e - (a * (c - 1) + b * (d - 1))
if c <= d:
	if e > c * a:
		t = a + (e - a * c) // d
	elif e <= c * a:
		t = e // c
elif c > d:
	if e > d * b:
		t = b + (e - b * d) // c
	elif e <= d * b:
		t = e // d
print(v, t)


a1f = int(input())
a2f = int(input())
c = int(input())
d = int(input())
if c <= d:
	k1 = c
	k2 = d
	a1 = a1f
	a2 = a2f
else:
	k1 = d
	k2 = c
	a1 = a2f
	a2 = a1f
n = int(input())
if n <= a1 * k1:
	M = n // k1
else:
	M = a1 + min((n - a1 * k1) // k2, a2)
t = a1 * (k1 - 1) + a2 * (k2 - 1)
if n <= t:
	m = 0
else:
	m = n - t
print(m, M)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mn = n
if n >= a1 * k1 + a2 * k2:
	print(a1 + a2, a1 + a2)
else:
	z1 = a1 * (k1 - 1)
	z2 = a2 * (k2 - 1)
	z = z1 + z2
	mn = mn - z
	if mn <= 0:
		print(0, end=' ')
	elif mn <= a1 + a2:
		print(mn, end=' ')
	else:
		print(a1 + a2)
	maxi = 0
	x = min(k1, k2)
	q1 = n // x
	if x == k1:
		if q1 <= a1:
			maxi += q1
			n -= q1 * k1
		else:
			maxi += a1
			n -= a1 * k1
	elif x == k2:
		if q1 <= a2:
			maxi += q1
			n -= q1 * k2
		else:
			maxi += a2
			n -= a2 * k2
	r = max(k1, k2)
	zx = 0
	if r == k1:
		zx = a1
	else:
		zx = a2
	q2 = n // r
	if q2 <= zx:
		maxi += q2
	else:
		maxi += zx
	print(maxi, end=' ')


def fxm(k1, k2, a1, a2, n):
	if k2 > k1:
		(k1, k2) = (k2, k1)
		(a1, a2) = (a2, a1)
	z = a1 * (k1 - 1)
	if z >= n:
		return 0
	n -= z
	y = a2 * (k2 - 1)
	if y >= n:
		return 0
	n -= y
	while a2 and n:
		if n >= k2:
			n -= k2
			a2 -= 1
			c += 1
		else:
			break
	return min(n, a1 + a2)

def fnm(k1, k2, a1, a2, n):
	if 1:
		if k2 > k1:
			(k1, k2) = (k2, k1)
			(a1, a2) = (a2, a1)
		c = 0
		while a2 and n:
			if n >= k2:
				n -= k2
				a2 -= 1
				c += 1
			else:
				break
		while a1 and n:
			if n >= k1:
				n -= k1
				a1 -= 1
				c += 1
			else:
				break
		return c

def fm(k1, k2, a1, a2, n):
	if 1:
		if k2 > k1:
			(k1, k2) = (k2, k1)
			(a1, a2) = (a2, a1)
		c = 0
		while a2 and n:
			if n >= k2:
				n -= k2
				a2 -= 1
				c += 1
			else:
				break
		while a1 and n:
			if n >= k1:
				n -= k1
				a1 -= 1
				c += 1
			else:
				break
		return c

def fmm(k1, k2, a1, a2, n):
	if k2 > k1:
		(k1, k2) = (k2, k1)
		(a1, a2) = (a2, a1)
	z = a1 * (k1 - 1)
	if z >= n:
		return 0
	n -= z
	y = a2 * (k2 - 1)
	if y >= n:
		return 0
	n -= y
	return min(n, a1 + a2)
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
for i in range(0):
	sksjs = 1
c = fm(k1, k2, a1, a2, n)
d = fmm(k1, k2, a1, a2, n)
print(d, c)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
nn = n
alpha = max(0, n - (a1 * (k1 - 1) + a2 * (k2 - 1)))
mn = -1
q = 0
for i in range(a1 + 1):
	for j in range(a2 + 1):
		if i * k1 + j * k2 <= n:
			q = max(q, i + j)
print(alpha, q)


(a1, a2, k1, k2, n) = (int(input()), int(input()), int(input()), int(input()), int(input()))
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
ma = min(a1, n // k1)
ma += min((a2, (n - ma * k1) // k2))
print(max(0, n - a1 * (k1 - 1) - a2 * (k2 - 1)), ma)


from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict
from bisect import bisect_left

def get_max(k1, k2, total, a1, a2):
	count = 0
	mn = 0
	while total > 0 and a2 > 0:
		total -= 1
		count += 1
		if count == k2:
			mn += 1
			count = 0
			a2 -= 1
	while total > 0 and a1 > 0:
		total -= 1
		count += 1
		if count == k1:
			mn += 1
			count = 0
			a1 -= 1
	return mn

def get_min(k1, k2, total, a1, a2):
	count = 0
	mn = 0
	total -= a1 * (k1 - 1) + a2 * (k2 - 1)
	count = 0
	while total > 0 and a2 > 0:
		total -= 1
		mn += 1
		a2 -= 1
	while total > 0 and a1 > 0:
		total -= 1
		mn += 1
		a1 -= 1
	return mn
a1 = int(stdin.readline().strip())
a2 = int(stdin.readline().strip())
k1 = int(stdin.readline().strip())
k2 = int(stdin.readline().strip())
total = int(stdin.readline().strip())
if k1 > k2:
	mx = get_max(k1, k2, total, a1, a2)
	mn = get_min(k1, k2, total, a1, a2)
else:
	mx = get_max(k2, k1, total, a2, a1)
	mn = get_min(k1, k2, total, a1, a2)
print(mn, mx)


import math

def getMin(n):
	x = a1 * (k1 - 1) + a2 * (k2 - 1)
	if n <= x:
		return 0
	return n - x

def getMax(n):
	x = min(n // k1, a1)
	n -= x * k1
	y = min(n // k2, a2)
	return x + y
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 > k2:
	[a1, a2] = [a2, a1]
	[k1, k2] = [k2, k1]
print(getMin(n), getMax(n))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
ni = n
if k2 < k1:
	maxout = min(n // k2, a2)
	n -= maxout * k2
	maxout += min(n // k1, a1)
	ni -= (k1 - 1) * a1 + (k2 - 1) * a2
	minout = max(0, ni)
	print(minout, maxout)
else:
	maxout = min(n // k1, a1)
	n -= maxout * k1
	maxout += min(n // k2, a2)
	ni -= (k1 - 1) * a1 + (k2 - 1) * a2
	minout = max(0, ni)
	print(minout, maxout)


import os

def f_min(a1, a2, k1, k2, n):
	n -= a1 * (k1 - 1)
	n -= a2 * (k2 - 1)
	return n if n > 0 else 0

def f_max(a1, a2, k1, k2, n):
	if k1 > k2:
		(k1, k2) = (k2, k1)
		(a1, a2) = (a2, a1)
	d = a1 * k1
	if n >= d:
		n -= d
		del1 = a1
	else:
		del1 = n // k1
		n -= del1 * k1
	d = a2 * k2
	if n >= d:
		n -= d
		del2 = a2
	else:
		del2 = n // k2
		n -= del2 * k2
	return del1 + del2

def f(a1, a2, k1, k2, n):
	return f'{f_min(a1, a2, k1, k2, n)} {f_max(a1, a2, k1, k2, n)}'
if os.environ.get('DEBUG', False):
	print(f'{f(2, 3, 5, 1, 8)} = 0 4')
	print(f'{f(3, 1, 6, 7, 25)} = 4 4')
	print(f'{f(6, 4, 9, 10, 89)} = 5 9')
else:
	print(f(int(input()), int(input()), int(input()), int(input()), int(input())))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
temp = (k1 - 1) * a1 + (k2 - 1) * a2
mini = 0
if temp < n:
	mini = n - temp
temp = k1 * a1 + a2 * k2
c1 = a1
c2 = a2
m1 = max(k1, k2)
if m1 == k2:
	c1 = a2
	c2 = a1
m2 = min(k1, k2)
while temp > n:
	if c1 > 0:
		temp = temp - m1
		c1 -= 1
	elif c2 > 0:
		temp = temp - m2
		c2 -= 1
maxi = c1 + c2
print(mini, maxi)


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))

def solve():
	a1 = ri()
	a2 = ri()
	k1 = ri()
	k2 = ri()
	n = ri()
	if k1 < k2:
		(a1, a2, k1, k2) = (a2, a1, k2, k1)
	L = [a1, a2, k1, k2, n]
	max_absorb = a1 * (k1 - 1) + a2 * (k2 - 1)
	m = max(0, n - max_absorb)
	M = 0
	while a2 > 0 and n >= k2:
		n -= k2
		M += 1
		a2 -= 1
	while a1 > 0 and n >= k1:
		n -= k1
		M += 1
		a1 -= 1
	print(m, M)
mode = 's'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
g = a1 * (k1 - 1) + a2 * (k2 - 1)
if n - g <= 0:
	print(0, end=' ')
else:
	print(n - g, end=' ')
if k1 < k2:
	h = k1 * a1
	if n < h:
		print(int(n // k1))
	elif n == h:
		print(a1)
	else:
		n -= h
		a1 = a1 + int(n // k2)
		print(a1)
else:
	h = k2 * a2
	if n < h:
		print(int(n // k2))
	elif n == h:
		print(a2)
	else:
		n -= h
		a2 = a2 + int(n // k1)
		print(a2)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mi = max(0, n - a1 * (k1 - 1) - a2 * (k2 - 1))
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
mx = min(n // k1, a1)
n -= mx * k1
mx += min(n // k2, a2)
print(mi, mx)


a = int(input())
b = int(input())
k1 = int(input())
k2 = int(input())
cards = int(input())
min_card = a * (k1 - 1) + b * (k2 - 1)
if cards <= min_card:
	print(0, end=' ')
else:
	print(cards - min_card, end=' ')
if k1 > k2:
	max_used = cards // k2
	if b >= max_used:
		print(max_used)
	else:
		max_used = b
		cards = cards - k2 * b
		max_used += cards // k1
		print(max_used)
else:
	max_used = cards // k1
	if a >= max_used:
		print(max_used)
	else:
		max_used = a
		cards = cards - k1 * a
		max_used += cards // k2
		print(max_used)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
N = int(input())
if a1 * (k1 - 1) + a2 * (k2 - 1) >= N:
	minNum = 0
else:
	minNum = min(a1 + a2, N - (a1 * (k1 - 1) + a2 * (k2 - 1)))
occ = [k1 for i in range(a1)] + [k2 for i in range(a2)]
occ.sort()
n = N
i = 0
maxNum = 0
for n in range(N):
	occ[i] -= 1
	if occ[i] == 0:
		maxNum += 1
		i += 1
print(minNum, maxNum)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
for _ in range(1):
	a1 = get_int()
	a2 = get_int()
	k1 = get_int()
	k2 = get_int()
	n = get_int()
	n1 = n
	if k1 > k2:
		(k1, k2) = (k2, k1)
		(a1, a2) = (a2, a1)
	x = min(n // k1, a1)
	mx = x
	n -= x * k1
	y = min(n // k2, a2)
	mx += y
	mi = max(0, n1 - a1 * (k1 - 1) - a2 * (k2 - 1))
	print(mi, mx)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
min = 0
max = 0
n1 = n
mx = 0
ch1 = ch2 = j1 = j2 = 0
if k1 < k2:
	ch1 = a1
	j1 = k1
	j2 = k2
	ch2 = a2
else:
	ch1 = a2
	j1 = k2
	j2 = k1
	ch2 = a1
mn = 0
if n <= j1 * ch1:
	mn = n / j1
	n = 0
else:
	mn = ch1
	n -= ch1 * j1
if n > 0:
	if n <= j2 * ch2:
		mn += n / j2
		n = 0
n = n1
k = a1 * (k1 - 1) + a2 * (k2 - 1)
n -= k
if n > ch1 + ch2:
	mx = ch1 + ch2
elif n > 0:
	mx = n
print(int(mx), ' ', int(mn))


I = input
a_1 = int(I())
a_2 = int(I())
k_1 = int(I())
k_2 = int(I())
num = int(I())
if num - a_1 * (k_1 - 1) - a_2 * (k_2 - 1) > 0:
	print(num - a_1 * (k_1 - 1) - a_2 * (k_2 - 1), end=' ')
else:
	print(0, end=' ')
if k_1 > k_2:
	n_1 = int(num / k_2) if num / k_2 < a_2 else a_2
	num -= n_1 * k_2
	n_2 = int(num / k_1) if num / k_1 < a_1 else a_1
	print(n_1 + n_2)
else:
	n_2 = int(num / k_1) if num / k_1 < a_1 else a_1
	num -= n_2 * k_1
	n_1 = int(num / k_2) if num / k_2 < a_2 else a_2
	print(n_1 + n_2)


def f1(a1, a2, k1, k2, n):
	res2 = min(a1, n // k1)
	rest = n - res2 * k1
	res2 += min(a2, rest // k2)
	return res2

def f2(a1, a2, k1, k2, n):
	n -= a2 * (k2 - 1)
	n -= a1 * (k1 - 1)
	return max(n, 0)
(a1, a2, k1, k2, n) = (int(input()), int(input()), int(input()), int(input()), int(input()))
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
print(f2(a1, a2, k1, k2, n), f1(a1, a2, k1, k2, n))


a = int(input())
b = int(input())
m = int(input())
n = int(input())
no = int(input())
if no - (m - 1) * a - (n - 1) * b > 0:
	print(no - (m - 1) * a - (n - 1) * b, end=' ')
else:
	print(0, end=' ')
k = min([m, n])
j = 0
l = 0
dup = 0
if k == m:
	j = a
	l = n
	dup = b
else:
	j = b
	l = m
	dup = a
if k * j >= no:
	print(no // k)
else:
	print(j + (no - j * k) // l)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
max = 0
min = 0
if k2 <= k1:
	if k2 * a2 < n:
		max += a2
		rn = n - k2 * a2
		max += int(rn / k1)
	else:
		max += int(n / k2)
if k1 < k2:
	if k1 * a1 < n:
		max += a1
		rn = n - k1 * a1
		max += int(rn / k2)
	else:
		max += int(n / k1)
minimp = a1 * (k1 - 1) + a2 * (k2 - 1)
if minimp >= n:
	min += 0
else:
	min += n - minimp
print(min, max)


a1 = int(input())
a2 = int(input())
b1 = int(input())
b2 = int(input())
n = int(input())
if b1 > b2:
	(a1, a2) = (a2, a1)
	(b1, b2) = (b2, b1)
minimum = n - a1 * (b1 - 1) - a2 * (b2 - 1)
minimum = max(0, min(a1 + a2, minimum))
a1_num = min(n // b1, a1)
n -= a1_num * b1
a2_num = min(n // b2, a2)
maximum = a1_num + a2_num
print(minimum, maximum)


n1 = int(input())
n2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 < k2:
	(k1, k2) = (k2, k1)
	(n1, n2) = (n2, n1)
mini = 0
maxi = 0
if (k1 - 1) * n1 + (k2 - 1) * n2 < n:
	mini = n - ((k1 - 1) * n1 + (k2 - 1) * n2)
if n2 * k2 < n:
	maxi = n2 + (n - n2 * k2) // k1
else:
	maxi = n // k2
print(mini, maxi)


from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 10 ** 5 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b):
	return abs(a[0] - b[0]) + abs(b[1] - a[1])

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN(x=' '):
	return list(map(int, sys.stdin.readline().strip().split(x)))

def eld(x, y):
	a = y[0] - x[0]
	b = x[1] - y[1]
	return (a * a + b * b) ** 0.5

def lgcd(a):
	g = a[0]
	for i in range(1, len(a)):
		g = math.gcd(g, a[i])
	return g

def ms(a):
	msf = -MAX
	meh = 0
	st = en = be = 0
	for i in range(len(a)):
		meh += a[i]
		if msf < meh:
			msf = meh
			st = be
			en = i
		if meh < 0:
			meh = 0
			be = i + 1
	return (msf, st, en)

def ncr(n, r):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % MOD
		den = den * (i + 1) % MOD
	return num * pow(den, MOD - 2, MOD) % MOD

def flush():
	return sys.stdout.flush()

def fac(n):
	ans = 1
	for i in range(1, n + 1):
		ans *= i
		ans %= MOD
	return ans
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if a1 * k1 + a2 * k2 == n:
	print(a1 + a2, a1 + a2)
else:
	if k1 > k2:
		if (k1 - 1) * a1 >= n:
			mn = 0
		else:
			rem = n - (k1 - 1) * a1
			if (k2 - 1) * a2 >= rem:
				mn = 0
			else:
				mn = rem - (k2 - 1) * a2
	elif (k2 - 1) * a2 >= n:
		mn = 0
	else:
		rem = n - (k2 - 1) * a2
		if (k1 - 1) * a1 >= rem:
			mn = 0
		else:
			mn = rem - (k1 - 1) * a1
	if k1 < k2:
		(x, y) = divmod(n, k1)
		if x <= a1:
			mx = x
		else:
			mx = a1
			rem = (x - a1) * k1 + y
			(p, q) = divmod(rem, k2)
			mx += p
	else:
		(x, y) = divmod(n, k2)
		if x <= a2:
			mx = x
		else:
			mx = a2
			rem = (x - a2) * k2 + y
			(p, q) = divmod(rem, k1)
			mx += p
	print(mn, mx)


def maxi(a, b, c, d, t):
	answer = 0
	while a:
		if t < b:
			return answer
		t -= b
		answer += 1
		a -= 1
	while c:
		if t < d:
			return answer
		t -= d
		answer += 1
		c -= 1
	return answer
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
total = int(input())
r = (k1 - 1) * a1 + (k2 - 1) * a2
minimal = min(a1 + a2, max(0, total - r))
print(minimal, max(maxi(a1, k1, a2, k2, total), maxi(a2, k2, a1, k1, total)))


(a, b, x, y, n) = [int(input()) for _ in range(5)]
z = n - a * (x - 1) - b * (y - 1)
t1 = min(n // x, a)
t2 = min(n // y, b)
k = max(t1 + min((n - x * t1) // y, b), t2 + min((n - y * t2) // x, a))
print(max(0, z), k)


import itertools
import sys
INF = sys.maxsize // 10

def compute(a1, a2, k1, k2, n):
	rest_cards = n
	rest_cards -= min(rest_cards, (k1 - 1) * a1 + (k2 - 1) * a2)
	cur_min = rest_cards
	cur_max = -INF
	for (i1, i2) in itertools.product(range(a1 + 1), range(a2 + 1)):
		num_cards = i1 * k1 + i2 * k2
		num_players = i1 + i2
		if num_cards <= n:
			cur_max = max(cur_max, num_players)
	return (cur_min, cur_max)

def main():
	a1 = int(input())
	a2 = int(input())
	k1 = int(input())
	k2 = int(input())
	n = int(input())
	print(*compute(a1, a2, k1, k2, n))
main()


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
z = min(k1, k2)
s = 0
s1 = 0
c = 0
if k1 == z:
	for i in range(0, a1):
		c += k1
		if n >= c:
			s += 1
		else:
			break
	for i in range(0, a2):
		c += k2
		if n >= c:
			s += 1
		else:
			break
else:
	for i in range(0, a2):
		c += k2
		if n >= c:
			s += 1
		else:
			break
	for i in range(0, a1):
		c += k1
		if n >= c:
			s += 1
		else:
			break
k1 = k1 - 1
k2 = k2 - 1
x = k1 * a1 + k2 * a2
if n <= x:
	print(0, s)
	exit(0)
else:
	print(min(n - x, a1 + a2), s)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
min = 0
max = 0
cnt = a1 * (k1 - 1) + a2 * (k2 - 1)
if (a1 < 1 or a2 < 1 or k1 < 1 or (k2 < 1) or (n < 1)) == True:
	print('Какое-то число меньше 1000')
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
min = n - cnt
if min < 0:
	min = 0
if n <= a1 * k1:
	max = int(n / k1)
else:
	max = int(a1 + (n - a1 * k1) / k2)
print(min, max)


(a1, a2, k1, k2, n) = [int(input()) for _ in range(5)]
if k1 > k2:
	(a1, a2, k1, k2) = (a2, a1, k2, k1)
x = min(a1, n // k1)
x += min(a2, (n - k1 * x) // k2)
print(max(0, n - a1 * (k1 - 1) - a2 * (k2 - 1)), x)


a = int(input())
b = int(input())
ka = int(input())
kb = int(input())
n = int(input())
if a * (ka - 1) + b * (kb - 1) > n:
	mi = 0
else:
	mi = min(n - (a * (ka - 1) + b * (kb - 1)), a + b)
if n // kb >= b:
	s = b
	ost = n - b * kb
	if ost // ka >= a:
		s += a
	else:
		s += ost // ka
else:
	s = n // kb
if n // ka >= a:
	s2 = a
	ost = n - a * ka
	if ost // kb >= b:
		s2 += b
	else:
		s2 += ost // kb
else:
	s2 = n // ka
ma = max(s, s2)
print(mi, ma)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
min_ans = 0
kyoyou = a1 * (k1 - 1) + a2 * (k2 - 1)
min_ans = min(a1 + a2, max(n - kyoyou, 0))
li = []
for i in range(a1):
	li.append(k1)
for i in range(a2):
	li.append(k2)
li = sorted(li)
max_ans = 0
for i in range(len(li)):
	if li[i] <= n:
		max_ans += 1
		n = n - li[i]
	else:
		break
print(min_ans, max_ans)


def solve(a1, a2, k1, k2, n):
	if k1 > k2:
		(a1, a2, k1, k2) = (a2, a1, k2, k1)
	mn = max(0, n - (k1 - 1) * a1 - (k2 - 1) * a2)
	mx = min(a1, n // k1) + (n - k1 * min(a1, n // k1)) // k2
	return (mn, mx)

def main():
	from sys import stdin
	(a1, a2, k1, k2, n) = [int(stdin.readline().strip()) for _ in range(5)]
	(mn, mx) = solve(a1, a2, k1, k2, n)
	print(mn, mx)
main()


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
naux = n
minn = 0
maxx = 0
for i in range(a1):
	if naux <= 0:
		break
	naux = naux - k1 + 1
for i in range(a2):
	if naux <= 0:
		break
	naux = naux - k2 + 1
if naux <= 0:
	minn = 0
elif naux > a1 + a2:
	print(a1 + a2)
else:
	minn = naux
naux = n
count = 0
if k1 < k2:
	menor = k1
	qmenor = a1
	maior = k2
	qmaior = a2
else:
	menor = k2
	qmenor = a2
	maior = k1
	qmaior = a1
for i in range(qmenor):
	naux = naux - menor
	if naux >= 0:
		count += 1
	else:
		break
for i in range(qmaior):
	naux = naux - maior
	if naux >= 0:
		count += 1
	else:
		break
maxx = count
print(minn, maxx)


import sys
from collections import defaultdict
input = lambda : sys.stdin.readline().rstrip()
(a1, a2, k1, k2, n) = (int(input()), int(input()), int(input()), int(input()), int(input()))
if k1 > k2:
	(a1, a2) = (a2, a1)
	(k1, k2) = (k2, k1)
x = 0
if (k1 - 1) * a1 + (k2 - 1) * a2 >= n:
	x = 0
else:
	x = min(a1 + a2, n - (k1 - 1) * a1 - (k2 - 1) * a2)
y = 0
if n >= k1 * a1:
	y = a1 + min(a2, (n - k1 * a1) // k2)
else:
	y = n // k1
print(x, y)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
m = 0
if k1 <= k2:
	a = a1 * k1
	m = min(a1, n // k1) + min(a2, (n - min(a1, n // k1) * k1) // k2)
	M = max(0, n - (a1 * (k1 - 1) + a2 * (k2 - 1)))
	print(M, m)
else:
	t = k2
	k2 = k1
	k1 = t
	t = a1
	a1 = a2
	a2 = t
	a = a1 * k1
	m = min(a1, n // k1) + min(a2, (n - min(a1, n // k1) * k1) // k2)
	M = max(0, n - (a1 * (k1 - 1) + a2 * (k2 - 1)))
	print(M, m)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
mi = max(0, n - (a1 * (k1 - 1) + a2 * (k2 - 1)))
if k1 < k2:
	p = min(n // k1, a1)
	p += min((n - p * k1) // k2, a2)
	print(mi, p)
else:
	p = min(n // k2, a2)
	p += min((n - p * k2) // k1, a1)
	print(mi, p)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
minPlayer = (k1 - 1) * a1 + (k2 - 1) * a2
if minPlayer >= n:
	minPlayer = 0
else:
	minPlayer = n - minPlayer
	if minPlayer > a1 + a2:
		minPlayer = a1 + a2
l = sorted([[k1, a1], [k2, a2]])
maxPlayer = 0
while n >= 0:
	if l[0][1] == 0 and l[1][1] == 0:
		maxPlayer += 1
		break
	elif l[0][1] > 0:
		n -= l[0][0]
		l[0][1] -= 1
		maxPlayer += 1
	elif l[1][1] > 0:
		n -= l[1][0]
		l[1][1] -= 1
		maxPlayer += 1
print(minPlayer, maxPlayer - 1)


import sys
from math import *
input = sys.stdin.readline
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : input().strip().split()
ls = lambda : list(input().strip())
from collections import defaultdict as df
import heapq
infinite = float('inf')
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
a11 = a1
a22 = a2
temp = n
c = 0
if k1 < k2:
	while temp > 0 and a1 > 0:
		temp -= k1
		a1 -= 1
		c += 1
	while temp > 0 and a2 > 0:
		temp -= k2
		a2 -= 1
		c += 1
	if temp < 0:
		c -= 1
else:
	while temp > 0 and a2 > 0:
		temp -= k2
		a2 -= 1
		c += 1
	while temp > 0 and a1 > 0:
		temp -= k1
		a1 -= 1
		c += 1
	if temp < 0:
		c -= 1
a1 = a11
a2 = a22
d = n - (a1 * (k1 - 1) + a2 * (k2 - 1))
m = 0
if d <= 0:
	m = 0
else:
	m = d
print(str(m) + ' ' + str(c))


import math
a11 = int(input())
a22 = int(input())
k11 = int(input())
k22 = int(input())
n = int(input())
q = []
if k11 < k22:
	a1 = a22
	a2 = a11
	k1 = k22
	k2 = k11
else:
	a1 = a11
	a2 = a22
	k1 = k11
	k2 = k22
q.append(max(n - a1 * (k1 - 1) - a2 * (k2 - 1), 0))
if n <= a2 * k2:
	q.append(math.floor(n / k2))
else:
	q.append(a2 + math.floor((n - a2 * k2) / k1))
print(str(q[0]) + ' ' + str(q[1]))


a = [int(input()), int(input())]
k = [int(input()), int(input())]
n = int(input())
n1 = n
n2 = n
p_max = 0
p_min = 0
if a[k.index(min(k))] < n1 // min(k):
	p_max += a[k.index(min(k))]
	n1 -= a[k.index(min(k))] * min(k)
	p_max += n1 // max(k)
else:
	p_max += n1 // min(k)
if n2 > a[0] * (k[0] - 1) + a[1] * (k[1] - 1):
	p_min += n2 - a[0] * (k[0] - 1) - a[1] * (k[1] - 1)
else:
	p_min = 0
print(p_min, p_max)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
minN = 0
maxN = 0
var = a1 * (k1 - 1) + a2 * (k2 - 1)
if var >= n:
	minN = 0
else:
	n1 = n
	n1 -= var
	minN = n1
if k1 > k2:
	if k2 * a2 >= n:
		maxN = n // k2
	else:
		n1 = n - k2 * a2
		maxN = a2 + n1 // k1
elif k1 * a1 >= n:
	maxN = n // k1
else:
	n1 = n - k1 * a1
	maxN = a1 + n1 // k2
print(minN, maxN)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
n1 = n
a = [a1, a2]
k = [k1, k2]
(total_max, total_min) = (0, 0)
low = k.index(min(k))
high = k.index(max(k))
total_max += min(n // k[low], a[low])
n -= total_max * k[low]
total_max += min(n // k[high], a[high])
thresh = (k1 - 1) * a1 + (k2 - 1) * a2
if n1 <= thresh:
	total_min = 0
else:
	total_min = n1 - thresh
print(total_min, total_max)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
p = n - (a1 * (k1 - 1) + a2 * (k2 - 1))
if p < 0:
	mn = 0
else:
	mn = p
if k1 < k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
q = n // k2
cnt = min(q, a2)
n -= cnt * k2
q = n // k1
cnt1 = min(q, a1)
mx = cnt + cnt1
print(mn, mx)


number_team_1 = int(input())
number_team_2 = int(input())
max_yellow_1 = int(input())
max_yellow_2 = int(input())
total_yellow = int(input())
min_cards = total_yellow
min_players = 0
max_players = 0
max_cards = total_yellow
min_cards -= number_team_1 * (max_yellow_1 - 1)
min_cards -= number_team_2 * (max_yellow_2 - 1)
if min_cards > 0:
	min_players = min_cards
else:
	min_players = 0
if max_yellow_1 <= max_yellow_2:
	max_cards -= number_team_1 * max_yellow_1
	max_players = number_team_1
	if max_cards > 0:
		max_players += max_cards // max_yellow_2
	else:
		max_players = total_yellow // max_yellow_1
else:
	max_cards -= number_team_2 * max_yellow_2
	max_players = number_team_2
	if max_cards > 0:
		max_players += max_cards // max_yellow_1
	else:
		max_players = total_yellow // max_yellow_2
print(str(min_players) + ' ' + str(max_players))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
cnt2 = n
cnt2 -= (k2 - 1) * a2 + (k1 - 1) * a1
min_res = max(cnt2, 0)
if k1 < k2:
	cnt = n
	max_res = min(n // k1, a1)
	cnt -= min(n // k1, a1) * k1
	max_res += cnt // k2
else:
	cnt = n
	max_res = min(n // k2, a2)
	cnt -= min(n // k2, a2) * k2
	max_res += cnt // k1
print(min_res, max_res)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
n1 = iinp()
n2 = iinp()
k1 = iinp()
k2 = iinp()
n = iinp()
mn = max(0, n - (k1 - 1) * n1 - (k2 - 1) * n2)
print(mn, end=' ')
if k2 < k1:
	x = min(n2, n // k2)
	x += min(n1, (n - x * k2) // k1)
	print(x)
else:
	y = min(n1, n // k1)
	y += min(n2, (n - y * k1) // k2)
	print(y)


aa = int(input())
bb = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 >= k2:
	a = (aa, k1)
	b = (bb, k2)
else:
	a = (bb, k2)
	b = (aa, k1)
(a, k1) = (a[0], a[1])
(b, k2) = (b[0], b[1])
if (k1 - 1) * a + (k2 - 1) * b >= n:
	mini = 0
else:
	mini = min(a + b, n - (k1 - 1) * a - (k2 - 1) * b)
maxi = min(n // k2, b)
n = n - maxi * k2
maxi += min(a, n // k1)
print(mini, maxi)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())

def most(a1, k1, a2, k2):
	if n <= a1 * k1:
		p = n // k1
	else:
		rem = n - a1 * k1
		p = a1
		p += min(rem // k2, a2)
	return p
mx = max(most(a1, k1, a2, k2), most(a2, k2, a1, k1))

def least(a1, k1, a2, k2):
	p = 0
	if n > a1 * (k1 - 1) + a2 * (k2 - 1):
		rem = n - a1 * (k1 - 1) - a2 * (k2 - 1)
		p = min(rem, a1 + a2)
	return p
mn = min(least(a1, k1, a2, k2), least(a2, k2, a1, k1))
print('%d %d' % (mn, mx))


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
r = n
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
c1 = 0
q = n // k1
q = min(q, a1)
n -= q * k1
c1 += q
q = n // k2
q = min(q, a2)
c1 += q
c2 = a1 * (k1 - 1) + a2 * (k2 - 1)
print(max(0, r - c2), c1)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
save_n = n
if k1 > k2:
	(k1, k2) = (k2, k1)
	(a1, a2) = (a2, a1)
nmax = 0
tobuy = min(a1, n // k1)
n -= k1 * tobuy
nmax += tobuy
tobuy = min(a2, n // k2)
n -= k2 * tobuy
nmax += tobuy
n = save_n
nmin = n - (k1 - 1) * a1 - (k2 - 1) * a2
if nmin < 0:
	nmin = 0
print(nmin, nmax)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
c = n - a1 * (k1 - 1) - a2 * (k2 - 1)
if c > 0:
	min = c
else:
	min = 0
if k1 > k2:
	k = k2
	a = a2
	ao = a1
	ko = k1
else:
	k = k1
	a = a1
	ao = a2
	ko = k2
if n >= a1 * k1 + a2 * k2:
	max = a1 + a2
elif a > n // k:
	max = n // k + n % k // ko
else:
	max = (n - a * k) // ko + a
print(min, max)


import math
a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
x = n
if k1 < k2:
	minArray = [a1, k1]
	maxArray = [a2, k2]
else:
	minArray = [a2, k2]
	maxArray = [a1, k1]
maxR = 0
minR = 0
maxR += min(n // minArray[1], minArray[0])
n -= maxR * minArray[1]
if n >= 0:
	maxR += min(n // maxArray[1], maxArray[0])
minR = max(0, x - maxArray[0] * (maxArray[1] - 1) - minArray[0] * (minArray[1] - 1))
print(minR, maxR)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
if k1 < k2:
	c = int(n / k1)
	if c <= a1:
		themax = c
	else:
		e = n - k1 * a1
		f = int(e / k2)
		if f < a2:
			themax = f + a1
		else:
			themax = a2 + a1
else:
	c = int(n / k2)
	if c <= a2:
		themax = c
	else:
		e = n - k2 * a2
		f = int(e / k1)
		if f < a1:
			themax = f + a2
		else:
			themax = a1 + c
g = (k1 - 1) * a1 + (k2 - 1) * a2
if g >= n:
	themin = 0
else:
	h = n - g
	if h > a1 + a2:
		themin = a1 + a2
	else:
		themin = h
if themax > a1 + a2:
	themax = a1 + a2
print(themin, themax)


a1 = int(input())
a2 = int(input())
k1 = int(input())
k2 = int(input())
n = int(input())
copyofn = n
countmax = 0
if k1 <= k2:
	for i in range(1, a1 + 1):
		if k1 <= copyofn:
			countmax += 1
			copyofn -= k1
	for i in range(1, a2 + 1):
		if k2 <= copyofn:
			countmax += 1
			copyofn -= k2
else:
	for i in range(1, a2 + 1):
		if k2 <= copyofn:
			countmax += 1
			copyofn -= k2
	for i in range(1, a1 + 1):
		if k1 <= copyofn:
			countmax += 1
			copyofn -= k1
copyofn = n
countmin = 0
v1 = a1 * (k1 - 1)
v2 = a2 * (k2 - 1)
if v1 + v2 >= copyofn:
	countmin = 0
else:
	countmin = copyofn - (v1 + v2)
print(countmin, countmax)