#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

const int N = 501000;
const int MOD = 1e9 + 7;

int n, t;
pair<int, int> ab[N];

bool comp(pair<int, int> i, pair<int, int> j)
{
    return 1LL * j.first * i.second - i.second < 1LL * i.first * j.second - j.second;
}

int dp[N][40];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> t;
    for (int i = 0; i < n; i++)
    {
        cin >> ab[i].first >> ab[i].second;
        ab[i].first++;
        ab[i].second++;
    }
    t++;
    sort(ab, ab + n, comp);
    int T = 1;
    int res = 0;
    vector<int> ones;
    for (int i = n - 1; i >= 0; i--)
    {
        if (ab[i].first == 1)
        {
            ones.push_back(ab[i].second);
            n--;
        }
    }
    sort(all(ones));
    for (int i = 0; i < ones.size(); i++)
    {
        if (i) ones[i] = ones[i - 1] + ones[i];
    }
    for (int i = 0; i < n; i++) for (int j = 0; j <= 30; j++) dp[i][j] = t + 1;
    for (int i = 0; i < n; i++)
    {
        //cout << ab[i].first << " " << ab[i].second << "\n";
        if (ab[i].first + ab[i].second <= t) dp[i][1] = ab[i].first + ab[i].second; else dp[i][1] = t + 1;
        dp[i][0] = 1;
    }
    for (int st = 2; st <= 30; st++)
    {
        int mn = t + 1;
        for (int i = 0; i < n; i++)
        {
            if (mn * ab[i].first + ab[i].second <= t)
            {
                dp[i][st] = mn * ab[i].first + ab[i].second;
            }
            else
            {
                dp[i][st] = t + 1;
            }
            mn = min(mn, dp[i][st - 1]);
        }
    }
    for (int sh = 0; sh <= 30; sh++)
    {
        for (int i = 0; i < n; i++)
        {
            int tot_time = dp[i][sh];
            int have_time = t - tot_time;
            if (have_time >= 0)
            {
                //cout << i << " " << sh << " " << have_time << " " << dp[i][sh] << "\n";
                int l = -1, r = ones.size();
                while (l + 1 < r)
                {
                    int mid = (l + r) / 2;
                    if (ones[mid] <= have_time) l = mid;
                    else r = mid;
                }
                res = max(res, l + 1 + sh);
            }
        }
    }
    for (int i = 0; i < ones.size(); i++)
    {
        if (1 + ones[i] <= t) res = max(res, i + 1);
    }
    cout << res;
}


Measured memory_bytes: 67840