#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
const int maxn = (long long)1e5 + 5;
const int mod = 1000000007;
const int inf = 0x3f3f3f3f;
pair<int, int> a[maxn], b[maxn];
int dp[105][maxn];
bool cmpa(const pair<int, int> &x, const pair<int, int> &y) {
  if (x.first == y.first) return x.second > y.second;
  return x.first < y.first;
}
bool cmpb(const pair<int, int> &x, const pair<int, int> &y) {
  return x.first + x.second > y.first + y.second;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, r;
  cin >> n >> r;
  int cnta = 0, cntb = 0;
  for (int i = 1; i <= n; ++i) {
    int x, y;
    cin >> x >> y;
    if (y >= 0)
      a[++cnta] = pair<int, int>(x, y);
    else
      b[++cntb] = pair<int, int>(x, y);
  }
  sort(a + 1, a + 1 + cnta, cmpa);
  sort(b + 1, b + 1 + cntb, cmpb);
  int ans = 0;
  for (int i = 1; i <= cnta; ++i) {
    if (r >= a[i].first) {
      ++ans;
      r += a[i].second;
    } else
      break;
  }
  int res = 0;
  for (int i = 1; i <= cntb; ++i) {
    if (r >= b[i].first && r >= abs(b[i].second)) {
      dp[i][r - abs(b[i].second)] = 1;
      res = max(res, 1);
      for (int j = i - 1; j >= 1; --j) {
        for (int k = max(abs(b[i].second), b[i].first); k <= (long long)6e4;
             ++k) {
          if (dp[j][k]) {
            dp[i][k - abs(b[i].second)] =
                max(dp[i][k - abs(b[i].second)], dp[j][k] + 1);
            res = max(res, dp[i][k - abs(b[i].second)]);
          }
        }
      }
    }
  }
  cout << ans + res;
  return 0;
}
