#include <bits/stdc++.h>
using namespace std;
int read() {
  int w = 0, f = 1;
  char c = ' ';
  while (c < '0' || c > '9') c = getchar(), f = c == '-' ? -1 : f;
  while (c >= '0' && c <= '9') w = w * 10 + c - 48, c = getchar();
  return w * f;
}
struct node {
  int a, b;
} t[105];
bool cmp(node x, node y) {
  if (x.b >= 0 && y.b < 0) return 1;
  if (x.b < 0 && y.b >= 0) return 0;
  if (x.b >= 0) return x.a == y.a ? x.b > y.b : x.a < y.a;
  return x.a + x.b == y.a + y.b ? x.b > y.b : x.a + x.b > y.a + y.b;
}
int n, m, dp[60005], ans;
signed main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) t[i].a = read(), t[i].b = read();
  sort(t + 1, t + n + 1, cmp);
  memset(dp, -1, sizeof(dp));
  dp[m] = 0;
  int it = 1;
  for (; it <= n && t[it].b >= 0; it++) {
    if (m < t[it].a) break;
    m += t[it].b;
    for (int i = 60005 - t[it].b - 1; i >= t[it].a; i--)
      if (dp[i] != -1) dp[i + t[it].b] = max(dp[i + t[it].b], dp[i] + 1);
  }
  while (t[it].b >= 0) it++;
  for (; it <= n; it++) {
    m += t[it].b;
    for (int i = max(t[it].a, -t[it].b); i < 60005; i++)
      if (dp[i] != -1) dp[i + t[it].b] = max(dp[i + t[it].b], dp[i] + 1);
  }
  for (int i = 0; i < 60005; i++) ans = max(ans, dp[i]);
  printf("%d", ans);
  return 0;
}
