#include <bits/stdc++.h>
using namespace std;
const int N = 110;
const int M = 6e4 + 100;
struct node {
  long long t, a;
  node(){};
  node(long long T, long long A) {
    t = T;
    a = A;
  }
} A[N], B[N];
bool cmp(node a, node b) { return a.t < b.t; }
bool cmp1(node a, node b) { return a.t + a.a > b.t + b.a; }
long long n, r, cnt1, cnt2, f[M], ans;
int main() {
  cin >> n >> r;
  for (long long i = 1; i <= n; i++) {
    long long t, a;
    cin >> t >> a;
    if (a > 0)
      A[++cnt1] = node(t, a);
    else
      B[++cnt2] = node(t, a);
  }
  sort(A + 1, A + 1 + cnt1, cmp);
  for (long long i = 1; i <= cnt1; i++) {
    if (r < A[i].t) break;
    r += A[i].a;
    ans++;
  }
  sort(B + 1, B + 1 + cnt2, cmp1);
  memset(f, -0x3f, sizeof(f));
  f[r] = ans;
  for (long long i = 1; i <= cnt2; i++) {
    for (long long j = max(B[i].t, -B[i].a); j <= r; j++) {
      f[j + B[i].a] = max(f[j + B[i].a], f[j] + 1);
      ans = max(ans, f[j + B[i].a]);
    }
  }
  cout << ans;
}
