#include <bits/stdc++.h>
using namespace std;
int mem[105][60500];
vector<pair<int, int>> vp, v;
bool cmp(pair<int, int> a, pair<int, int> b) {
  int tmpa = max(a.first, -a.second), tmpb = max(b.first, -b.second);
  int ai = tmpa + a.second, bi = tmpb + b.second;
  if (ai <= bi) {
    return false;
  } else {
    return true;
  }
}
int solve(int ind, int re) {
  if (re < 0) {
    return -1e8;
  }
  if (ind == vp.size()) {
    return 0;
  }
  if (mem[ind][re] != -1) {
    return mem[ind][re];
  }
  int ch1 = 0;
  int ch2 = solve(ind + 1, re);
  if (re >= vp[ind].first) {
    ch1 = solve(ind + 1, re + vp[ind].second) + 1;
  }
  return mem[ind][re] = max(ch1, ch2);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, r;
  cin >> n >> r;
  pair<int, int> pr[n];
  for (int i = 0; i < n; i++) {
    cin >> pr[i].first >> pr[i].second;
    if (pr[i].second >= 0) {
      v.push_back({pr[i].first, pr[i].second});
    } else {
      vp.push_back({pr[i].first, pr[i].second});
    }
  }
  sort(v.begin(), v.end());
  sort(vp.begin(), vp.end(), cmp);
  int cnt = 0;
  for (int i = 0; i < v.size(); i++) {
    if (v[i].first <= r) {
      r += v[i].second;
      cnt++;
    } else {
      break;
    }
  }
  memset(mem, -1, sizeof mem);
  cnt += solve(0, r);
  cout << cnt << endl;
  return 0;
}
