#include <bits/stdc++.h>
using namespace std;
long long n, s, x, y, nb;
vector<pair<long long, long long> > t, v;
long long dp[102];
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return a.first + a.second > b.first + b.second;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> s;
  for (long long i = 0; i < n; i++) {
    cin >> x >> y;
    if (y >= 0) {
      t.push_back(make_pair(x, y));
    } else {
      v.push_back(make_pair(y, x));
    }
  }
  sort(t.begin(), t.end());
  for (long long i = 0; i < t.size(); i++) {
    if (t[i].first > s) break;
    s += t[i].second;
    nb++;
  }
  sort(v.begin(), v.end(), cmp);
  n = v.size();
  for (long long i = 1; i < n + 1; i++) dp[i] = -1;
  dp[0] = s;
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j > 0; j--) {
      if (dp[j - 1] >= v[i].second) dp[j] = max(dp[j], dp[j - 1] + v[i].first);
    }
  }
  long long i;
  for (i = n; dp[i] == -1; i--)
    ;
  cout << nb + i << "\n";
  return 0;
}
