#include <bits/stdc++.h>
using namespace std;
struct node1 {
  int a, b;
  friend bool operator<(const node1 &a, const node1 &b) { return a.a < b.a; }
};
struct node2 {
  int a, b;
  friend bool operator<(const node2 &a, const node2 &b) {
    return a.a + a.b > b.a + b.b;
  }
};
int n, r;
vector<node1> v1;
vector<node2> v2;
int bas;
int dp[7000005];
int main() {
  cin >> n >> r;
  for (int i = 1; i <= n; i++) {
    int a, b;
    cin >> a >> b;
    if (b >= 0)
      v1.push_back((node1){a, b});
    else
      v2.push_back((node2){a, b});
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  for (int i = 0; i < v1.size(); i++) {
    if (r >= v1[i].a) {
      r += v1[i].b;
      bas++;
    }
  }
  memset(dp, -1, sizeof(dp));
  dp[r] = 0;
  for (int i = 0; i < v2.size(); i++) {
    for (int j = v2[i].a; j <= r; j++) {
      if (dp[j] != -1 && j + v2[i].b >= 0) {
        dp[j + v2[i].b] = max(dp[j + v2[i].b], dp[j] + 1);
      }
    }
  }
  int ans = 0;
  for (int j = r; j >= 0; j--) ans = max(ans, dp[j]);
  cout << bas + ans;
  return 0;
}
