#include <bits/stdc++.h>
using namespace std;
const long long infl = 0x3f3f3f3f3f3f3f3fLL;
const long long infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
const long long mod = 1e9 + 7;
const long long N = 6e4 + 5;
long long dp[105][N];
bool cmp(pair<long long, long long> p, pair<long long, long long> q) {
  return p.first + p.second > q.first + q.second;
}
void solve() {
  long long n, r;
  cin >> n >> r;
  vector<pair<long long, long long>> pos, neg;
  for (long long i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    if (b >= 0)
      pos.push_back({a, b});
    else {
      if (a + b < 0) a = -b;
      neg.push_back({a, b});
    }
  }
  sort(pos.begin(), pos.end());
  sort(neg.begin(), neg.end(), cmp);
  memset(dp, -1, sizeof dp);
  dp[0][r] = 0;
  for (long long i = 0; i < ((long long)pos.size()); i++) {
    for (long long j = 0; j < N; j++) {
      dp[i + 1][j] = dp[i][j];
      if (j >= pos[i].first + pos[i].second && dp[i][j - pos[i].second] != -1)
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - pos[i].second] + 1);
    }
  }
  for (long long i = 0; i < ((long long)neg.size()); i++) {
    for (long long j = 0; j < N - 500; j++) {
      dp[i + ((long long)pos.size()) + 1][j] =
          dp[i + ((long long)pos.size())][j];
      if (j >= neg[i].first + neg[i].second &&
          dp[i + ((long long)pos.size())][j - neg[i].second] != -1)
        dp[i + ((long long)pos.size()) + 1][j] =
            max(dp[i + ((long long)pos.size()) + 1][j],
                dp[i + ((long long)pos.size())][j - neg[i].second] + 1);
    }
  }
  long long ans = 0;
  for (long long i = 0; i < N; i++) ans = max(ans, dp[n][i]);
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  long long t = 1;
  while (t--) solve();
  return 0;
}
long long powm(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
long long divide(long long a, long long b) {
  return (a % mod) * powm(b, mod - 2) % mod;
}
long long norm(long long a) {
  while (a >= mod) a -= mod;
  while (a < 0) a += mod;
  return a;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
