#include <bits/stdc++.h>
using namespace std;
int n, r;
struct node {
  int a, b;
} nod[105];
inline bool cmp(node n1, node n2) {
  if (n1.b >= 0 && n2.b >= 0)
    return n1.a < n2.a;
  else if (n1.b < 0 && n2.b < 0)
    return n1.a + n1.b < n2.a + n2.b;
  else
    return n1.b >= 0;
}
int dp[100005];
int main() {
  while (~scanf("%d%d", &n, &r)) {
    for (int i = 1; i <= n; ++i) scanf("%d%d", &nod[i].a, &nod[i].b);
    sort(nod + 1, nod + n + 1, cmp);
    memset(dp, 0, sizeof(dp));
    int cnt = 0;
    int i = 1;
    for (; i <= n; ++i) {
      if (r >= nod[i].a && nod[i].b >= 0)
        r += nod[i].b, ++cnt;
      else if (nod[i].b < 0)
        break;
    }
    for (; i <= n; ++i) {
      for (int j = r; j >= max(nod[i].a, -nod[i].b); --j)
        dp[j] = max(dp[j], dp[j + nod[i].b] + 1);
    }
    printf("%d\n", dp[r] + cnt);
  }
  return 0;
}
