#include <bits/stdc++.h>
using namespace std;
struct node {
  int a, b;
  friend bool operator<(node x, node y) {
    if (x.b < 0 && y.b < 0) return x.a + x.b > y.a + y.b;
    return x.a < y.a;
  }
} a[105];
vector<node> b, c;
int n, m;
int f[105][300005];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &a[i].a, &a[i].b);
    if (a[i].b > 0)
      b.push_back(a[i]);
    else
      c.push_back(a[i]);
  }
  sort(b.begin(), b.end()), sort(c.begin(), c.end());
  int ans = 0, res = 0;
  for (int i = 0; i < b.size(); ++i) {
    if (m >= b[i].a)
      m += b[i].b, ans++;
    else
      break;
  }
  for (int i = 0; i < c.size(); ++i) {
    for (int j = c[i].a; j <= m; ++j) {
      if (j + c[i].b < 0) continue;
      f[i + 1][j + c[i].b] = max(f[i][j] + 1, f[i][j + c[i].b]);
      res = max(res, f[i + 1][j + c[i].b]);
    }
  }
  cout << res + ans << endl;
  return 0;
}
