#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  ;
  int n, r;
  cin >> n >> r;
  int x = 0, y = 0;
  pair<long long, long long> pos[n];
  pair<int, pair<long long, long long>> neg[n];
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (b < 0) {
      neg[y++] = make_pair(max(a, -b) + b, make_pair(a, b));
    } else {
      pos[x++] = make_pair(a, b);
    }
  }
  sort(pos, pos + x);
  sort(neg, neg + y, greater<pair<int, pair<long long, long long>>>());
  bool ans = true;
  int z = 0;
  for (int i = 0; i < x; i++) {
    if (r >= pos[i].first) {
      r += pos[i].second;
      z++;
    }
  }
  pair<long long, long long> dp[y + 1][r + 1];
  for (int i = 0; i <= r; i++) {
    dp[0][i] = make_pair(0, r);
  }
  for (int i = 1; i <= y; i++) {
    for (int j = 0; j < -neg[i - 1].second.second; j++) {
      dp[i][j] = dp[i - 1][j];
    }
    for (int j = -neg[i - 1].second.second; j <= r; j++) {
      if (dp[i - 1][j + neg[i - 1].second.second].first + 1 >
              dp[i - 1][j].first &&
          dp[i - 1][j + neg[i - 1].second.second].second >=
              neg[i - 1].second.first) {
        dp[i][j] = make_pair(dp[i - 1][j + neg[i - 1].second.second].first + 1,
                             dp[i - 1][j + neg[i - 1].second.second].second +
                                 neg[i - 1].second.second);
      } else {
        if (dp[i][j - 1].first > dp[i - 1][j].first ||
            (dp[i][j - 1].first == dp[i - 1][j].first &&
             dp[i][j - 1].second > dp[i - 1][j].second)) {
          dp[i][j] = dp[i][j - 1];
        } else {
          dp[i][j] = dp[i - 1][j];
        }
      }
    }
  }
  cout << z + dp[y][r].first;
}
