#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long n, m, a, b, c, k, temp, x, y;
const int MAXN = 1e5 + 11;
inline long long max(long long a, long long b) { return ((a > b) ? a : b); }
inline long long min(long long a, long long b) { return ((a > b) ? b : a); }
inline long long gcd(long long a, long long b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
inline vector<long long> read(int n) {
  vector<long long> v(n);
  for (int i = 0; i < v.size(); i++) cin >> v[i];
  return v;
}
bool comp(const pair<long long, long long> &p1,
          const pair<long long, long long> &p2) {
  if (p1.first + p1.second > p2.second + p2.first) return true;
  if (p1.first + p1.second == p2.second + p2.first) return p1.first > p2.first;
  return false;
}
int dp[101][60001];
vector<pair<long long, long long> > p, np;
int f(int i, int r) {
  int &ans = dp[i][r];
  if (i == n) return ans = 0;
  if (ans != -1) return ans;
  ans = 0;
  if (r >= np[i].first && r + np[i].second >= 0)
    ans = 1 + f(i + 1, r + np[i].second);
  ans = max(ans, f(i + 1, r));
  return ans;
}
void sol() {
  memset(dp, -1, sizeof(dp));
  int r, cnt = 0;
  cin >> n >> r;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (b < 0)
      np.push_back({a, b});
    else
      p.push_back({a, b});
  }
  sort(p.begin(), p.end());
  for (auto x : p)
    if (r >= x.first)
      r += x.second, cnt++;
    else
      break;
  n = np.size();
  sort(np.begin(), np.end(), comp);
  cout << cnt + f(0, r);
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int test = 1;
  for (int i = 1; i <= test; i++) sol();
}
