#include <bits/stdc++.h>
using namespace std;
long long n, r, a, b, ans, ans2, top, dp[105][60305];
vector<pair<long long, long long> > myvec, myvotr;
bool fcmp(pair<long long, long long> a, pair<long long, long long> b) {
  return (a.first < b.first);
}
bool fcmpotr(pair<long long, long long> a, pair<long long, long long> b) {
  return (a.first + a.second > b.first + b.second);
}
void vse() {
  cout << "NO";
  exit(0);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> r;
  for (int i = 1; i <= n; i++) {
    cin >> a >> b;
    if (b >= 0)
      myvec.push_back(make_pair(a, b));
    else
      myvotr.push_back(make_pair(max(a, -b), b));
  }
  sort(myvec.begin(), myvec.end(), fcmp);
  sort(myvotr.begin(), myvotr.end(), fcmpotr);
  for (int i = 0; i < myvec.size(); i++)
    if (myvec[i].first > r)
      break;
    else {
      ans++;
      r += myvec[i].second;
    }
  dp[0][r] = ans;
  for (int i = 0; i < myvotr.size(); i++)
    for (int j = 0; j <= r; j++) {
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
      if (r + myvotr[i].second >= 0 && j >= myvotr[i].first)
        dp[i + 1][j + myvotr[i].second] =
            max(dp[i + 1][j + myvotr[i].second], dp[i][j] + 1);
    }
  top = (long long)myvotr.size();
  for (int j = 0; j <= r; j++) ans2 = max(ans2, dp[top][j]);
  cout << ans2;
  return 0;
}
