#include <bits/stdc++.h>
using namespace std;
int n, r, ans;
struct node {
  int a, b;
  bool operator<(const node &y) const { return a < y.a; }
  bool operator>(const node &y) const { return a > y.a; }
};
vector<node> pos, neg;
priority_queue<int, vector<int>, greater<int> > q;
inline void prework() {
  scanf("%d%d", &n, &r);
  node d;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &d.a, &d.b);
    if (d.b < 0)
      neg.push_back(d);
    else
      pos.push_back(d);
  }
  sort(pos.begin(), pos.end());
  int l = neg.size();
  for (int i = 0; i < l; i++) {
    neg[i].a += neg[i].b;
    neg[i].a = max(neg[i].a, 0);
  }
  sort(neg.begin(), neg.end());
  reverse(neg.begin(), neg.end());
}
inline void mainwork() {
  ans = 0;
  int l = pos.size();
  for (int i = 0; i < l; i++)
    if (r >= pos[i].a) r += pos[i].b, ans++;
  l = neg.size();
  for (int i = 0; i < l; i++) {
    r += neg[i].b;
    q.push(neg[i].b);
    if (r < neg[i].a) {
      r -= q.top();
      q.pop();
    }
  }
  ans += q.size();
}
inline void print() { printf("%d\n", ans); }
int main() {
  prework();
  mainwork();
  print();
  return 0;
}
