#include <bits/stdc++.h>
using namespace std;
int n, r, Ans;
vector<pair<int, int>> vP;
vector<pair<int, int>> vN;
int dp[101][30001];
bool Comp(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first + a.second > b.first + b.second);
}
int Solve(int i, int r) {
  if (r < 0) return -1;
  if (i == vN.size()) return 0;
  if (dp[i][r] != -1) return dp[i][r];
  dp[i][r] = max((r >= vN[i].first ? Solve(i + 1, r + vN[i].second) + 1 : 0),
                 Solve(i + 1, r));
  return dp[i][r];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> n >> r;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    if (y < 0)
      vN.push_back(make_pair(x, y));
    else
      vP.push_back(make_pair(x, y));
  }
  sort(vP.begin(), vP.end());
  for (auto &it : vP) {
    if (r >= it.first) r += it.second, Ans++;
  }
  sort(vN.begin(), vN.end(), Comp);
  memset(dp, -1, sizeof(dp));
  cout << Solve(0, r) + Ans;
}
