#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void cinar(long long* ar, long long n) {
  for (long long i = 0; i < n; i++) cin >> ar[i];
}
void out(long long* a, long long n) {
  for (long long i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
long long powexp(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
long long powexp(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
long long modInverse(long long a, long long p) { return powexp(a, p - 2, p); }
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
bool comp(const pair<long long, long long>& a,
          const pair<long long, long long>& b) {
  return a.first + a.second > b.first + b.second;
}
int main() {
  fast();
  long long n, r;
  cin >> n >> r;
  vector<pair<long long, long long> > v1;
  long long c = 0;
  vector<pair<long long, pair<long long, long long> > > v2;
  for (long long i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    if (b >= 0)
      v1.push_back(make_pair(a, b));
    else
      v2.push_back(make_pair(a + b, make_pair(max(a, abs(b)), b)));
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  reverse(v2.begin(), v2.end());
  for (long long i = 0; i < v1.size(); i++) {
    if (v1[i].first <= r) {
      r += v1[i].second;
      c++;
    }
  }
  long long dp[v2.size() + 1][r + 1];
  for (long long i = 0; i < v2.size() + 1; i++) {
    for (long long j = 0; j < r + 1; j++) {
      dp[i][j] = 0;
    }
  }
  for (long long i = 0; i < v2.size() + 1; i++) {
    for (long long w = 0; w < r + 1; w++) {
      if (w == 0 || i == 0)
        dp[i][w] = 0;
      else if ((w >= v2[i - 1].second.first) &&
               (w + v2[i - 1].second.second >= 0)) {
        dp[i][w + v2[i - 1].second.second] =
            max(dp[i - 1][w + v2[i - 1].second.second], dp[i - 1][w] + 1);
        dp[i][w] = max(dp[i][w], dp[i - 1][w]);
      } else {
        dp[i][w] = max(dp[i][w], dp[i - 1][w]);
      }
    }
  }
  long long an = 0;
  for (long long i = 0; i < r + 1; i++) {
    an = max(an, dp[v2.size()][i]);
  }
  cout << an + c;
}
