#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int dp[200005][35],t[200005];
P<int,int> a[200005];
bool cmp(P<int,int> x,P<int,int> y){
	RE x.F*(y.S+1)>y.F*(x.S+1);
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	int la,lt;
	la=lt=0;
	P<int,int> in;
	FOR(i,1,n){
		cin>>in.F>>in.S;
		if(in.F){
			a[++la]=in;
		}else t[++lt]=in.S+1;
	}
	sort(t+1,t+lt+1);
	FOR(i,1,lt)t[i]=t[i]+t[i-1];
	FOR(i,0,la)FOR(j,1,30)dp[i][j]=m+1;
	sort(a+1,a+la+1,cmp);
	FOR(i,1,la){
		FOR(j,1,30){
			dp[i][j]=min(dp[i-1][j],dp[i-1][j-1]+1+(dp[i-1][j-1]+1)*a[i].F+a[i].S);
		}
	}
	int ans=0,ind;
	FOR(i,0,30){
		if(dp[la][i]>m)continue;
		ind=upb(t+1,t+lt+1,m-dp[la][i])-t;
		gmax(ans,i+ind-1);
	}
	cout<<ans;
	RE 0;
}


