#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 + 5;
const int MAXM = 30000 * 2 + 5;
int n, r, np, nn;
struct Project {
  int a, b;
} pos[MAXN], neg[MAXN];
int dp[MAXM];
int main() {
  int a, b;
  ios::sync_with_stdio(false);
  cin >> n >> r;
  int totalNeg = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b;
    if (b >= 0) {
      pos[np++] = {a, b};
    } else {
      neg[nn++] = {a, b};
      totalNeg -= b;
    }
  }
  sort(pos, pos + np,
       [](const Project &a, const Project &b) { return a.a < b.a; });
  int cnt = 0;
  for (int i = 0; i < np; ++i) {
    if (r >= pos[i].a) {
      r += pos[i].b;
      ++cnt;
    }
  }
  if (r >= 0) {
    memset(dp, -1, sizeof(dp));
    sort(neg, neg + nn, [](const Project &a, const Project &b) {
      if (a.a + a.b == b.a + b.b) {
        return a.a > b.a;
      }
      return a.a + a.b > b.a + b.b;
    });
    dp[r] = 0;
    for (int i = 0; i < nn; ++i) {
      for (int j = 0; j <= r; ++j) {
        if (dp[j] != -1 && j >= neg[i].a && j + neg[i].b >= 0) {
          dp[j + neg[i].b] = max(dp[j + neg[i].b], dp[j] + 1);
        }
      }
    }
    int maxNeg = 0;
    for (int i = 0; i <= r; ++i) {
      maxNeg = max(maxNeg, dp[i]);
    }
    cnt += maxNeg;
  }
  cout << cnt << endl;
  return 0;
}
