#include <bits/stdc++.h>
using namespace std;
const long long N = 200200, M = 110, K = 30030, Inf = 1e17;
void Max(long long &x, long long y) { x = max(x, y); }
long long dp[4 * K];
long long a[M], b[M];
vector<pair<long long, long long>> p, neg;
bool cmp(pair<long long, long long> p1, pair<long long, long long> p2) {
  return p1.first - p1.second < p2.first - p2.second;
}
int main() {
  long long n, r, c = 0;
  cin >> n >> r;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    if (b[i] >= 0)
      p.push_back({a[i], b[i]});
    else
      neg.push_back({a[i], -b[i]});
  }
  sort(p.begin(), p.end());
  for (int i = 0; i < p.size(); i++) {
    if (p[i].first <= r) r += p[i].second, c++;
  }
  sort(neg.begin(), neg.end(), cmp);
  for (int i = 0; i < neg.size(); i++) {
    for (int j = 2 * K - 1; j >= neg[i].first; j--) {
      if (j - neg[i].second >= 0) Max(dp[j], dp[j - neg[i].second] + 1);
    }
  }
  long long Ans = 0;
  for (int i = 0; i <= r; i++) {
    Max(Ans, dp[i]);
  }
  Ans += c;
  cout << Ans << '\n';
  return 0;
}
