#include <bits/stdc++.h>
using namespace std;
long long n, rating;
long long level[30008], devote[30008];
long long p[30008];
long long cmp(long long x, long long y) {
  if (devote[x] >= 0 and devote[y] < 0) return 1;
  if (devote[x] < 0 and devote[y] >= 0) return 0;
  if (devote[x] >= 0 and devote[y] >= 0) {
    return level[x] < level[y];
  }
  if (devote[x] < 0 and devote[y] < 0) {
    return level[x] + devote[x] > level[y] + devote[y];
  }
  assert(0);
}
signed main() {
  scanf("%lld%lld", &n, &rating);
  for (long long i = 1; i <= n; i++)
    scanf("%lld%lld", &level[i], &devote[i]), p[i] = i;
  sort(p + 1, p + n + 1, cmp);
  long long ans = 0;
  multiset<long long> corrupt;
  for (long long i = 1; i <= n; i++) {
    long long x = p[i];
    if (devote[x] >= 0) {
      if (level[x] <= rating) ans++, rating += devote[x];
    } else {
      if (level[x] <= rating and rating + devote[x] >= 0) {
        ans++;
        corrupt.insert(devote[x]);
        rating += devote[x];
      } else {
        rating += devote[x];
        corrupt.insert(devote[x]);
        rating -= *corrupt.begin();
        corrupt.erase(corrupt.begin());
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
