#include <bits/stdc++.h>
using namespace std;
struct node {
  int a, b;
} p[110];
inline bool cmp1(node a, node b) { return a.b > b.b; }
inline bool cmp2(node a, node b) { return a.a < b.a; }
inline bool cmp3(node a, node b) { return a.a + a.b > b.a + b.b; }
int n, m, flag, ans1 = -1, ans2, f[102][60300];
int main() {
  n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> p[i].a >> p[i].b;
  sort(p + 1, p + 1 + n, cmp1);
  for (int i = n; i; i--)
    if (p[i].b >= 0) {
      flag = i;
      break;
    }
  sort(p + 1, p + flag + 1, cmp2);
  for (int i = flag + 1; i <= n; i++) p[i].a = max(p[i].a, -p[i].b);
  sort(p + flag + 1, p + 1 + n, cmp3);
  for (int i = 1; i <= flag; i++) {
    if (m < p[i].a) {
      ans1 = i - 1;
      break;
    }
    m += p[i].b;
  }
  if (ans1 == -1) ans1 = flag;
  for (int i = 1 + flag; i <= n; i++) {
    memcpy(f[i + 1], f[i], sizeof(f[i + 1]));
    for (int j = p[i].a; j <= m; j++) {
      f[i + 1][j + p[i].b] = max(f[i + 1][j + p[i].b], f[i][j] + 1);
      ans2 = max(ans2, f[i + 1][j + p[i].b]);
    }
  }
  printf("%d", ans1 + ans2);
  return 0;
}
