#include <bits/stdc++.h>
using namespace std;
int n, r;
pair<int, int> a[105];
int memo[105][70005];
vector<pair<int, int>> aa, bb;
int solve(int idx, int nw) {
  if (idx == bb.size()) return 0;
  int& ret = memo[idx][nw];
  if (~ret) return ret;
  if (bb[idx].first <= nw && nw + bb[idx].second >= 0)
    ret = 1 + solve(idx + 1, nw + bb[idx].second);
  ret = max(ret, solve(idx + 1, nw));
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> r;
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first >> a[i].second;
    if (a[i].second >= 0)
      aa.emplace_back(a[i]);
    else
      bb.emplace_back(a[i]);
  }
  int c = 0;
  sort(aa.begin(), aa.end());
  for (auto a : aa) {
    if (r >= a.first) {
      r += a.second;
      ++c;
    }
  }
  sort(bb.begin(), bb.end(),
       [](const pair<int, int>& x, const pair<int, int>& y) {
         return x.first - y.second > y.first - x.second;
       });
  memset(memo, -1, sizeof memo);
  cout << c + solve(0, r) << '\n';
  return 0;
}
