#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
struct node {
  int v, w;
  node() {}
  node(int x, int y) : v(x), w(y) {}
  bool operator<(const node& tl) const { return (v - w) < (tl.v - tl.w); }
} z[105], f[105];
bool cmp(node aa, node bb) { return aa.v < bb.v; }
int dp[30005 * 2] = {0};
int main() {
  int n, m, tot1, tot2;
  cin >> n >> m;
  tot1 = tot2 = 1;
  for (int i = 1; i < n + 1; ++i) {
    int x, y;
    cin >> x >> y;
    if (y < 0)
      f[tot2++] = node(x, -y);
    else
      z[tot1++] = node(x, y);
  }
  sort(z + 1, z + tot1, cmp);
  int ans = 0;
  for (int i = 1; i < tot1; ++i) {
    if (z[i].v <= m) {
      m += z[i].w;
      ++ans;
    }
  }
  sort(f + 1, f + tot2);
  int sum = 0;
  for (int i = 1; i < tot2; ++i) {
    for (int j = m; j >= max(f[i].v, f[i].w); --j) {
      dp[j] = max(dp[j], dp[j - f[i].w] + 1);
    }
  }
  cout << ans + dp[m] << '\n';
  return 0;
}
