#include <bits/stdc++.h>
using namespace std;
int n, r;
vector<pair<int, int> > Pos;
const int N = 1e5 + 100;
vector<int> e[N];
int main() {
  cin >> n >> r;
  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 {
      e[max(0, x + y)].push_back(-y);
    }
  }
  sort(Pos.begin(), Pos.end());
  int cnt = 0;
  for (auto x : Pos) {
    if (r >= x.first) r += x.second, cnt++;
  }
  priority_queue<int, vector<int>, greater<int> > heap;
  for (int remain = 0; remain <= r; ++remain) {
    for (int x : e[remain]) heap.push(x);
    while (!heap.empty()) {
      int u = heap.top();
      if (remain + u > r) break;
      int t = remain + u;
      heap.pop();
      ++cnt;
      ++remain;
      while (remain <= t) {
        for (int x : e[remain]) heap.push(x);
        ++remain;
      }
      --remain;
    }
  }
  cout << cnt;
}
