#include <bits/stdc++.h>
using namespace std;
int n, a[200002], f[200002], ans, r, dp[200002], s;
struct Node {
  int a, b;
} d[200002];
bool cmp1(Node x, Node y) { return x.a < y.a; }
bool cmp2(Node x, Node y) { return x.b > y.b; }
bool cmp3(Node x, Node y) { return x.b + x.a < y.b + y.a; }
bool cmp4(Node x, Node y) { return x.b < y.b; }
inline int read() {
  int x = 0;
  char c = getchar();
  bool flag = 0;
  while (c < '0' || c > '9') {
    if (c == '-') flag = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  return flag ? -x : x;
}
inline void write(int x) {
  int num = 0;
  char c[15];
  while (x) c[++num] = (x % 10) + 48, x /= 10;
  while (num) putchar(c[num--]);
}
long long max(long long x, long long y) {
  if (x > y) {
    return x;
  } else {
    return y;
  }
}
long long min(long long x, long long y) {
  if (x < y) {
    return x;
  } else {
    return y;
  }
}
int main() {
  cin >> n >> r;
  for (int i = 1; i <= n; i++) {
    cin >> d[i].a >> d[i].b;
  }
  sort(d + 1, d + n + 1, cmp2);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (d[i].b < 0) {
      break;
    } else {
      cnt = i;
    }
  }
  sort(d + 1, d + cnt + 1, cmp1);
  for (int i = 1; i <= cnt; i++) {
    if (r < d[i].a) {
      break;
    } else {
      r += d[i].b;
      ans++;
    }
  }
  sort(d + cnt + 1, d + n + 1, cmp3);
  for (int i = cnt + 1; i <= n; i++) {
    for (int j = r; j >= max(d[i].a, -d[i].b); j--) {
      dp[j] = max(dp[j], dp[j + d[i].b] + 1);
    }
  }
  for (int i = 1; i <= r; i++) {
    s = max(s, dp[i]);
  }
  ans += s;
  cout << ans << endl;
}
