output_description: Print the answer.
  
  * * *
input_description: 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
attempt: import numpy as np
  import sys
  
  input = sys.stdin.readline
  
  n, t = map(int, input().split())
  l_a0 = []
  l_a1 = []
  
  for i in range(n):
      tmp = list(map(int, input().split()))
      if tmp[0] == 0:
          l_a0.append(tmp)
      else:
          tmp.append(float(0))
          l_a1.append(tmp)
  
  l_a0 = np.array(l_a0)
  l_a1 = np.array(l_a1)
  
  if len(l_a0) == 0:
      for i in range(len(l_a1)):
          l_a1[i][2] = float(l_a1[i][0] / (l_a1[i][1] + 1))
      l_a1 = l_a1[np.argsort(l_a1[:, 2])[::-1]]
  
      ans = 0
      tmp = 0
      for i in range(len(l_a1)):
          if tmp + 1 + l_a1[i][0] * (tmp + 1) + l_a1[i][0] <= t:
              tmp += 1 + l_a1[i][0] * (tmp + 1) + l_a1[i][0]
              ans += 1
  
      print(ans)
  
  elif len(l_a1) == 0:
      l_a0 = l_a0[np.argsort(l_a0[:, 1])]
      ans = 0
      tmp = 0
      for i in range(len(l_a0)):
          if tmp + 1 + l_a0[i][1] <= t:
              tmp += l_a0[i][1]
              ans += 1
  
      print(ans)
  
  else:
      l_a0 = l_a0[np.argsort(l_a0[:, 1])]
      for i in range(len(l_a1)):
          l_a1[i][2] = float(l_a1[i][0] / (l_a1[i][1] + 1))
          l_a1 = l_a1[np.argsort(l_a1[:, 2])[::-1]]
  
      dp = [[float("inf")] * 4 for i in range(len(l_a1) + 1)]
      dp[0][0] = 0
      for i in range(1, len(l_a1) + 1):
          for j in range(4):
              dp[i][j] = min(
                  dp[i - 1][j],
                  (
                      dp[i - 1][j - 1]
                      + 1
                      + l_a1[i - 1][0] * (dp[i - 1][j - 1] + 1)
                      + l_a1[i - 1][1]
                  ),
              )
      ans = 0
      for i in range(4):
          judge = dp[-1][i]
          if judge >= t:
              break
          tmp = i
          for j in range(len(l_a0)):
              if judge + 1 + l_a0[j][1] <= t:
                  judge += l_a0[j][1]
                  tmp += 1
              else:
                  break
          if tmp >= ans:
              ans = tmp
  
      print(ans)
  
problem_description: Statement
  
  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.
samples: [{"input": "3 7\n    2 0\n    3 2\n    0 3", "output": "2\n    \n\nHere is one possible way to visit stores:\n\n  * From time 0 to time 1: in 1 unit of time, he travels from his house to Store 1.\n  * From time 1 to time 3: for 2 units of time, he stands in a queue for Store 1 to do shopping.\n  * From time 3 to time 4: in 1 unit of time, he travels from Store 1 to Store 3.\n  * From time 4 to time 7: for 3 units of time, he stands in a queue for Store 3 to do shopping.\n\nIn this way, he can do shopping twice before time 7.5.\n\n* * *"}, {"input": "1 3\n    0 3", "output": "0\n    \n\n* * *"}, {"input": "5 21600\n    2 14\n    3 22\n    1 3\n    1 10\n    1 9", "output": "5\n    \n\n* * *"}, {"input": "7 57\n    0 25\n    3 10\n    2 4\n    5 15\n    3 22\n    2 14\n    1 15", "output": "3"}]