There are N stores called Store 1, Store 2, \cdots, Store N. Takahashi, who is at his house at time 0, is planning to visit some of these stores.

It takes Takahashi one unit of time to travel from his house to one of the stores, or between any two stores.

If Takahashi reaches Store i at time t, he can do shopping there after standing in a queue for a_i \times t + b_i units of time. (We assume that it takes no time other than waiting.)

All the stores close at time T + 0.5. If Takahashi is standing in a queue for some store then, he cannot do shopping there.

Takahashi does not do shopping more than once in the same store.

Find the maximum number of times he can do shopping before time T + 0.5.

Constraints

* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 0 \leq a_i \leq 10^9
* 0 \leq b_i \leq 10^9
* 0 \leq T \leq 10^9

Input

Input is given from Standard Input in the following format:


N T
a_1 b_1
a_2 b_2
\vdots
a_N b_N


Output

Print the answer.

Examples

Input

3 7
2 0
3 2
0 3


Output

2


Input

1 3
0 3


Output

0


Input

5 21600
2 14
3 22
1 3
1 10
1 9


Output

5


Input

7 57
0 25
3 10
2 4
5 15
3 22
2 14
1 15


Output

3

Difficulty: UNKNOWN_DIFFICULTY

Solutions:
import sys
readline = sys.stdin.buffer.readline
INF = 10 ** 18 + 3
(N, T) = map(int, readline().split())
AB = [tuple(map(int, readline().split())) for _ in range(N)]
ABzero = [b for (a, b) in AB if a == 0]
ABnonzero = [(a, b) for (a, b) in AB if a]
ABnonzero.sort(key=lambda x: (x[1] + 1) / x[0])
dp = [0]
for (a, b) in ABnonzero:
	dp2 = dp + [INF]
	for j in range(1, len(dp2)):
		dp2[j] = min(dp2[j], (dp[j - 1] + 1) * (a + 1) + b)
	dp = [d for d in dp2 if d <= T]
ABzero.sort()
dpzero = [0] + [b + 1 for b in ABzero]
for i in range(1, len(dpzero)):
	dpzero[i] += dpzero[i - 1]
DP = [INF] * (N + 1)
for i in range(len(dp)):
	for j in range(len(dpzero)):
		DP[i + j] = min(DP[i + j], dp[i] + dpzero[j])
DP = [d for d in DP if d <= T]
print(max(0, len(DP) - 1))


import bisect
import sys
input = sys.stdin.readline
(N, T) = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]
a0 = []
nab = []
for (a, b) in AB:
	if a == 0:
		a0.append(b)
	else:
		nab.append(((b + 1) / a, a, b))
a0.sort()
nab.sort()
a0sum = []
_sum = 0
for b in a0:
	_sum += 1 + b
	a0sum.append(_sum)
INF = 1 << 32
dp = [0] + [INF] * 29
for (index, (_, a, b)) in enumerate(nab):
	ndp = [0] + [INF] * 29
	for count in range(1, 29):
		ndp[count] = min(dp[count], dp[count - 1] + 1 + (dp[count - 1] + 1) * a + b)
	dp = ndp
ans = 0
for (count, t) in enumerate(dp):
	if t > T:
		continue
	v = bisect.bisect_right(a0sum, T - t)
	ans = max(ans, v + count)
print(ans)


import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10 ** 9 + 7
input = lambda : sys.stdin.readline().rstrip()
from bisect import bisect_right
from itertools import accumulate
from functools import cmp_to_key

def cmp(store1, store2):
	if store1 == store2:
		return 0
	(a1, b1) = store1
	(a2, b2) = store2
	return -1 if a2 * (b1 + 1) <= a1 * (b2 + 1) else 1

def resolve():
	(n, T) = map(int, input().split())
	AB = []
	zero = []
	for _ in range(n):
		(a, b) = map(int, input().split())
		if a != 0:
			AB.append((a, b))
		else:
			zero.append(b + 1)
	AB.sort(key=cmp_to_key(cmp))
	zero.sort()
	zero = list(accumulate(zero))
	max_store = 30
	dp = [T + 1] * max_store
	dp[0] = 0
	for (a, b) in AB:
		for i in range(max_store - 2, -1, -1):
			t = dp[i]
			dp[i + 1] = min(dp[i + 1], (a + 1) * (t + 1) + b)
	res = 0
	for i in range(max_store):
		t = dp[i]
		if t > T:
			break
		rest = T - t
		res = max(res, i + bisect_right(zero, rest))
	print(res)
resolve()


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

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

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

class Store:

	def __init__(self, a, b):
		self.a = a
		self.b = b

	def __eq__(self, other):
		return (self.b + 1) * other.a == self.a * (other.b + 1)

	def __lt__(self, other):
		return (self.b + 1) * other.a < self.a * (other.b + 1)

	def __le__(self, other):
		return (self.b + 1) * other.a <= self.a * (other.b + 1)

	def __gt__(self, other):
		return (self.b + 1) * other.a > self.a * (other.b + 1)

	def __ge__(self, other):
		return (self.b + 1) * other.a >= self.a * (other.b + 1)
from itertools import accumulate
from bisect import bisect

def main():
	inf = 10 ** 9 + 7
	(n, t) = MI()
	ab = LLI(n)
	ss = []
	a0 = []
	for (a, b) in ab:
		if a == 0:
			a0.append(b + 1)
		else:
			ss.append(Store(a, b))
	n = len(ss)
	ss.sort()
	dp = [[inf] * 31 for _ in range(n + 1)]
	dp[0][0] = 0
	for (i, s) in enumerate(ss):
		(a, b) = (s.a, s.b)
		for j in range(30):
			pre = dp[i][j]
			if pre == inf:
				continue
			nt = a * (pre + 1) + b + pre + 1
			if nt <= t:
				dp[i + 1][j + 1] = min(dp[i + 1][j + 1], nt)
			dp[i + 1][j] = min(dp[i + 1][j], pre)
	a0.sort()
	a0 = [b for b in accumulate(a0)]
	ans = 0
	for j in range(30):
		val = dp[n][j]
		if val == inf:
			continue
		ans = max(ans, bisect(a0, t - dp[n][j]) + j)
	print(ans)
main()


import sys
from bisect import bisect_right
(N, T) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
b0 = []
ab1 = []
for (a, b) in ab:
	if a == 0:
		b0.append(b + 1)
	else:
		ab1.append([(b + 1) / a, a, b])
N0 = len(b0)
N1 = len(ab1)
b0.sort()
if N0 > 0:
	b_ruiseki = [0] * N0
	b_ruiseki[0] = b0[0]
	for i in range(1, N0):
		b_ruiseki[i] = b_ruiseki[i - 1] + b0[i]
else:
	b_ruiseki = []
ab1.sort()
INF = T + 100
dp = [[INF] * 31 for _ in range(N1 + 1)]
dp[0][0] = 0
ans = 0
for i in range(N1):
	for j in range(31):
		if j > i + 1:
			break
		if j == 0:
			dp[i + 1][j] = 0
		else:
			dp[i + 1][j] = min(dp[i][j], (dp[i][j - 1] + 1) * (ab1[i][1] + 1) + ab1[i][2])
for j in range(31):
	if dp[N1][j] > T:
		break
	num0 = bisect_right(b_ruiseki, T - dp[N1][j])
	ans = max(ans, j + num0)
print(ans)


import sys
input = sys.stdin.readline
(N, T) = map(int, input().split())
M = [list(map(int, input().split())) for i in range(N)]

def compare(x, y):
	if x == 0:
		return (1 << 31) + y
	else:
		return (y + 1) / x
M.sort(key=lambda x: compare(x[0], x[1]))
k = N
for i in range(N):
	if M[i][0] == 0:
		k = i
		break
DP = [[T + 1] * (k + 1) for i in range(30)]
for i in range(k + 1):
	DP[0][i] = 0

def nexttime(x, a, b):
	return x + 1 + a * (x + 1) + b
for i in range(1, 30):
	for j in range(1, k + 1):
		nt = nexttime(DP[i - 1][j - 1], M[j - 1][0], M[j - 1][1])
		DP[i][j] = min(DP[i][j - 1], nt)
ANS = 0
for i in range(30):
	TIME = min(DP[i])
	if TIME > T:
		break
	SC = i
	for j in range(k, N):
		if TIME + M[j][1] + 1 <= T:
			TIME += M[j][1] + 1
			SC += 1
	ANS = max(ANS, SC)
print(ANS)