#include <bits/stdc++.h>
using namespace std;
int q;
long long int n;
long long int ans, sum;
long long int gcd(long long int a, long long int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long int powe(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = (res * a);
    }
    a = (a * a);
    b /= 2;
  }
  return res;
}
long long int power(long long int a, long long int b, long long int M) {
  a %= M;
  long long int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = (res * a) % M;
    }
    a = (a * a) % M;
    b /= 2;
  }
  return res;
}
long long int extendedEuclid(long long int A, long long int B, long long int &x,
                             long long int &y) {
  if (B == 0) {
    x = 1;
    y = 0;
    return A;
  } else {
    long long int x1, y1;
    long long int gcd = extendedEuclid(B, A % B, x1, y1);
    y = x1 - (A / B) * y1;
    x = y1;
    return gcd;
  }
}
long long int mi(long long int A, long long int M) {
  long long int x, y;
  extendedEuclid(A, M, x, y);
  if (x < 0) {
    x += (long long int)1000000007;
  }
  return x;
}
vector<bool> sieve(1000000, true);
void Sieve() {
  sieve[0] = false;
  sieve[1] = false;
  for (long long int i = 2; i * i <= 1000000; i++) {
    if (sieve[i] == true) {
      for (long long int j = i * i; j < 1000000; j += i) sieve[j] = false;
    }
  }
}
vector<long long int> sieve_spf;
void Sieve_spf() {
  const long long int n = 1e6 + 5;
  sieve_spf.resize(n);
  for (int i = 0; i < n; i++) sieve_spf[i] = i;
  sieve_spf[0] = -1;
  sieve_spf[1] = 1;
  for (int i = 2; i <= n; i += 2) sieve_spf[i] = 2;
  for (int i = 3; i <= n; i += 2)
    if (sieve_spf[i] == i)
      for (int j = i * i; j <= n; j += i)
        if (sieve_spf[j] == j) sieve_spf[j] = i;
}
bool isUpcase(char c) {
  if (c >= 'A' && c <= 'Z')
    return true;
  else
    return false;
}
bool islowcase(char c) {
  if (c >= 'a' && c <= 'z')
    return true;
  else
    return false;
}
void the_happiest_place_on_earth() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
}
bool comp(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first < b.first && a.second >= 0 && b.second >= 0)
    return true;
  else if (a.second < 0 && b.second < 0 &&
           a.first + a.second > b.first + b.second)
    return true;
  else
    return false;
}
const int N = 1900055;
long long int m[N], a[N];
long long int dp[105][30005];
vector<pair<int, int>> v2;
long long int dpp(int i, int r) {
  if (i >= v2.size()) return dp[i][r] = 0;
  if (dp[i][r] != -1) return dp[i][r];
  int res = 0;
  if (r + v2[i].second >= 0 && r >= v2[i].first) {
    res = max(1 + dpp(i + 1, r + v2[i].second), dpp(i + 1, r));
  } else
    res = dpp(i + 1, r);
  return dp[i][r] = res;
}
void testcase() {
  long long int r;
  cin >> n >> r;
  int expctd = r;
  vector<pair<int, int>> v1;
  for (int i = 0; i < n; i++) {
    int req, del;
    cin >> req >> del;
    if (del >= 0)
      v1.push_back({req, del});
    else
      v2.push_back({req, del});
  }
  ans = 0;
  memset(dp, -1, sizeof(dp));
  sort(v1.begin(), v1.end(), comp);
  for (auto x : v1) {
    if (r >= x.first) r += x.second, ans++;
  }
  sort(v2.begin(), v2.end(), comp);
  ans += dpp(0, r);
  cout << ans;
  return;
}
int main() {
  the_happiest_place_on_earth();
  q = 1;
  while (q--) {
    testcase();
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
