#include <bits/stdc++.h>
using namespace std;
const long long o = 101;
const long long p = 6e4;
struct qwq {
  long long x, y;
} a[o], b[o];
long long n, m, l, r, f[p + 1], ans = -1;
bool cmp1(qwq u, qwq v) { return u.x == v.x ? u.y > v.y : u.x < v.x; }
bool cmp2(qwq u, qwq v) { return u.x + u.y > v.x + v.y; }
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 1, x, y; i <= n; i++) {
    cin >> x >> y;
    if (y >= 0)
      a[++l] = (qwq){x, y};
    else
      b[++r] = (qwq){x, y};
  }
  memset(f, -1, sizeof(f)), f[m] = 0;
  sort(a + 1, a + l + 1, cmp1), sort(b + 1, b + r + 1, cmp2);
  for (long long i = 1; i <= l; i++)
    for (long long j = p; j >= a[i].x; j--)
      if (f[j] != -1) f[j + a[i].y] = max(f[j] + 1, f[j + a[i].y]);
  for (long long i = 1; i <= r; i++)
    for (long long j = max(b[i].x, -b[i].y); j <= p; j++)
      if (f[j] != -1) f[j + b[i].y] = max(f[j] + 1, f[j + b[i].y]);
  for (long long i = 0; i <= p; i++) ans = max(f[i], ans);
  cout << ans;
  return 0;
}
