#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 105;
const int MAX_R = 30004;
const int MOD = 1e9 + 7;
int n, rat;
vector<pair<int, int> > pos, neg;
pair<int, int> curr;
int memo[MAX_N][MAX_R];
int dp(int ind, int cR) {
  int &r = memo[ind][cR];
  if (r != -1) return r;
  if (ind >= n) return 0;
  pair<int, int> it = neg[ind];
  r = dp(ind + 1, cR);
  if (max(cR + it.second, it.first + it.second) <= rat)
    r = max(r, 1 + dp(ind + 1, max(cR + it.second, it.first + it.second)));
  return r;
}
int canDoPos() {
  sort(pos.begin(), pos.end());
  int it = 0;
  while (it < pos.size() and pos[it].first <= rat) rat += pos[it++].second;
  return it;
}
int main() {
  memset(memo, -1, sizeof memo);
  scanf("%d%d", &n, &rat);
  while (n--) {
    scanf("%d%d", &curr.first, &curr.second);
    if (curr.second >= 0)
      pos.push_back(curr);
    else {
      curr.second += curr.first;
      curr.first -= curr.second;
      swap(curr.first, curr.second);
      curr.first = max(curr.first, 0);
      neg.push_back(curr);
    }
  }
  int res = canDoPos();
  sort(neg.begin(), neg.end());
  n = neg.size();
  res += dp(0, 0);
  printf("%d\n", res);
  return 0;
}
