#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
template <typename T>
using Pair = array<T, 2>;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, r;
  while (cin >> n >> r) {
    vector<pair<int, int>> pos;
    vector<pair<int, int>> neg;
    for (int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      if (b >= 0) {
        pos.emplace_back(a, b);
      } else {
        neg.emplace_back(a, b);
      }
    }
    sort(pos.begin(), pos.end());
    int c = 0;
    for (int i = 0; i < pos.size(); i++) {
      if (r >= pos[i].first) {
        r += pos[i].second;
        c++;
      }
    }
    int maxcc = 0;
    ;
    ;
    ;
    for (int s = 0; s < r; s++) {
      int cc = 0;
      int ss = s;
      vector<int> used(neg.size());
      for (int i = 0; i < neg.size(); i++) {
        int maxb = -1e9;
        int id = -1;
        for (int j = 0; j < neg.size(); j++) {
          if (used[j]) {
            continue;
          }
          if (ss - neg[j].second >= neg[j].first) {
            if (maxb < neg[j].second) {
              maxb = neg[j].second;
              id = j;
            }
          }
        }
        if (id == -1 || ss - maxb > r) {
          break;
        }
        ss -= maxb;
        cc++;
        used[id] = true;
      };
      maxcc = max(maxcc, cc);
    }
    cout << maxcc + c << endl;
  }
}
