#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 110;
const int MAX_R = 3e4 + 100;
int n, r;
pair<int, int> p[2][MAX_N];
int idx[2];
int a[MAX_N];
bool cmp(pair<int, int> a, pair<int, int> b) {
  return a.first + a.second > b.first + b.second;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> r;
  int ai, bi;
  for (int i = 0; i < n; ++i) {
    cin >> ai >> bi;
    int id = (bi < 0);
    p[id][idx[id]].first = ai;
    p[id][idx[id]++].second = bi;
  }
  sort(p[0], p[0] + idx[0]);
  int ans = 0;
  for (int i = 0; i < idx[0]; ++i) {
    if (r >= p[0][i].first) {
      r += p[0][i].second;
      ++ans;
    }
  }
  int m = idx[1];
  sort(p[1], p[1] + m, cmp);
  vector<vector<int> > dp(m + 1, vector<int>(r + 1, 0));
  dp[0][r] = ans;
  for (int i = 0; i < m; ++i) {
    for (int cr = 0; cr <= r; ++cr) {
      if (cr >= p[1][i].first && cr + p[1][i].second >= 0) {
        dp[i + 1][cr + p[1][i].second] =
            max(dp[i + 1][cr + p[1][i].second], dp[i][cr] + 1);
      }
      dp[i + 1][cr] = max(dp[i + 1][cr], dp[i][cr]);
    }
  }
  ans = 0;
  for (int cr = 0; cr <= r; ++cr) ans = max(ans, dp[m][cr]);
  cout << ans << endl;
  return 0;
}
