#include <bits/stdc++.h>
using namespace std;
int n, r, cnt1, cnt2, ans, f[105][60005], res;
struct node {
  int x, y;
} a[10005], b[10005];
inline int read() {
  int ret = 0, ff = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') ff = -ff;
    ch = getchar();
  }
  while (isdigit(ch)) {
    ret = (ret << 3) + (ret << 1) + ch - '0';
    ch = getchar();
  }
  return ret * ff;
}
void write(int x) {
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + 48);
}
inline bool cmp1(node A, node B) { return A.x < B.x; }
inline bool cmp2(node A, node B) { return A.x + A.y > B.x + B.y; }
signed main() {
  n = read(), r = read();
  for (int i = 1; i <= n; i++) {
    int x = read(), y = read();
    if (y >= 0)
      a[++cnt1] = (node){x, y};
    else
      b[++cnt2] = (node){x, y};
  }
  sort(a + 1, a + cnt1 + 1, cmp1);
  int now = r;
  for (int i = 1; i <= cnt1; i++) {
    if (now >= a[i].x) {
      ans++;
      now += a[i].y;
    } else
      break;
  }
  sort(b + 1, b + cnt2 + 1, cmp2);
  for (int i = 1; i <= cnt2; i++) {
    if (now >= b[i].x && now >= abs(b[i].y)) {
      f[i][now - abs(b[i].y)] = 1;
      res = max(res, 1);
      for (int j = i - 1; j >= 1; j--)
        for (int k = max(abs(b[i].y), b[i].x); k <= 60000; k++)
          if (f[j][k]) {
            f[i][k - abs(b[i].y)] = max(f[i][k - abs(b[i].y)], f[j][k] + 1);
            res = max(res, f[i][k - abs(b[i].y)]);
          }
    }
  }
  write(ans + res);
  return 0;
}
