#include <bits/stdc++.h>
#pragma optimize GCC("O3")
using namespace std;
bool cmp(pair<int, int> p1, pair<int, int> p2) {
  if (p2.second < 0 && p1.second >= 0) return true;
  if (p1.second < 0 && p2.second >= 0) return false;
  if (p1.second < 0) {
    return p1.first + p1.second > p2.first + p2.second;
  } else {
    return p1.first < p2.first;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, r;
  cin >> n >> r;
  vector<pair<int, int> > p;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    a = max(a, -b);
    p.push_back(make_pair(a, b));
  }
  sort(p.begin(), p.end(), cmp);
  const int maxr = 100000;
  vector<vector<int> > dp(n + 1, vector<int>(maxr, -1));
  dp[0][r] = 0;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = p[i - 1].first; j < min(maxr, maxr - p[i - 1].second); j++) {
      if (dp[i - 1][j] != -1)
        dp[i][j + p[i - 1].second] =
            max(dp[i][j + p[i - 1].second], dp[i - 1][j] + 1);
    }
    for (int j = 0; j < maxr; j++) {
      dp[i][j] = max(dp[i][j], dp[i - 1][j]);
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}
