#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n, r, dp[maxn], cnt;
vector<pair<int, int> > pos, neg;
int main() {
  scanf("%d%d", &n, &r);
  for (int i = 1; i <= n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (b >= 0)
      pos.push_back({a, b});
    else
      neg.push_back({a + b, b});
  }
  sort(pos.begin(), pos.end());
  for (auto &x : pos) {
    int a = x.first, b = x.second;
    if (r >= a)
      r += b, cnt++;
    else
      break;
  }
  sort(neg.begin(), neg.end());
  reverse(neg.begin(), neg.end());
  dp[r] = cnt;
  for (auto &x : neg) {
    int a = x.first, b = x.second;
    a -= b;
    for (int i = max(a, -b); i <= r; i++) dp[i + b] = max(dp[i + b], dp[i] + 1);
  }
  printf("%d", *max_element(dp, dp + r + 1));
  return 0;
}
