#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> a, pair<int, int> b) {
  return a.first + a.second > b.first + b.second;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, r;
  cin >> n >> r;
  vector<pair<int, int> > pos, neg;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    if (y >= 0)
      pos.push_back(pair<int, int>(x, y));
    else
      neg.push_back(pair<int, int>(max(x, -y), y));
  }
  sort(pos.begin(), pos.end());
  sort(neg.begin(), neg.end(), cmp);
  int cur = 0;
  for (int i = 0; i < pos.size(); i++) {
    pair<int, int> e = pos[i];
    if (r >= e.first) {
      r += e.second;
      cur++;
    }
  }
  vector<vector<int> > dp(neg.size() + 1, vector<int>(r + 1, 0));
  dp[0][r] = cur;
  for (int i = 0; i < (int)neg.size(); i++) {
    for (int k = 0; k <= r; k++) {
      if (k >= neg[i].first && k + neg[i].second >= 0)
        dp[i + 1][k + neg[i].second] =
            max(dp[i + 1][k + neg[i].second], dp[i][k] + 1);
      dp[i + 1][k] = max(dp[i + 1][k], dp[i][k]);
    }
  }
  int sol = 0;
  for (int i = 0; i <= r; i++) sol = max(sol, dp[(int)neg.size()][i]);
  cout << sol << '\n';
  return 0;
}
