#include <bits/stdc++.h>
using namespace std;
struct node1 {
  int num, d;
  bool operator<(const node1& b) const { return num > b.num; }
};
struct node2 {
  int num, d;
  bool operator<(const node2& b) const { return num < b.num; }
};
priority_queue<node1> q1;
priority_queue<node2> q2;
priority_queue<int, vector<int>, greater<int> > q;
int main() {
  int n, r;
  int tmp1, tmp2;
  scanf("%d%d", &n, &r);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &tmp1, &tmp2);
    if (tmp2 >= 0) {
      node1 tmp;
      tmp.num = tmp1;
      tmp.d = tmp2;
      q1.push(tmp);
    } else {
      node2 tmp;
      tmp.num = tmp1 + tmp2;
      tmp.num = max(tmp.num, 0);
      tmp.d = tmp2;
      q2.push(tmp);
    }
  }
  while (!q1.empty()) {
    node1 tmp = q1.top();
    q1.pop();
    if (r < tmp.num) {
      continue;
    }
    r += tmp.d;
    ans++;
  }
  while (!q2.empty()) {
    node2 tmp = q2.top();
    q2.pop();
    r += tmp.d;
    q.push(tmp.d);
    if (r < tmp.num) {
      r -= q.top();
      q.pop();
    }
  }
  ans += q.size();
  printf("%d\n", ans);
  return 0;
}
