#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > q;
vector<pair<int, int> > g;
int dp[111][111111];
int main() {
  int n, r;
  int k = 0;
  cin >> n >> r;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (b >= 0)
      g.push_back(make_pair(a, b));
    else
      q.push_back(make_pair(a, b));
  }
  sort(g.begin(), g.end());
  for (int i = 0; i < g.size(); i++) {
    if (r >= g[i].first) {
      r = r + g[i].second;
      k++;
    }
  }
  for (int i = 0; i < q.size(); i++) {
    q[i].first = max(q[i].first, -q[i].second);
    q[i].first = -(q[i].first + q[i].second);
  }
  sort(q.begin(), q.end());
  for (int i = 0; i < q.size(); i++) {
    q[i].first = -q[i].first - q[i].second;
  }
  for (int i = 0; i < q.size(); i++) {
    for (int j = 0; j <= r; j++) {
      if (j >= q[i].first && j + q[i].second >= 0) {
        dp[i + 1][j + q[i].second] =
            max(dp[i][j] + 1, dp[i + 1][j + q[i].second]);
      }
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
    }
  }
  int res = 0;
  for (int i = 0; i <= r; i++) {
    res = max(res, dp[q.size()][i]);
  }
  cout << res + k;
}
