#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
std::string printVector(const std::vector<T> &data) {
  std::stringstream ss;
  std::ostream_iterator<T> out_it(ss, ", ");
  ss << "[";
  std::copy(data.begin(), data.end() - 1, out_it);
  ss << data.back() << "]";
  return ss.str();
}
template <typename T>
void print_array(const T &ary, int size) {
  for (int i = (0); i < (size); ++i) {
    cout << ary[i] << " ";
  }
  cout << endl;
}
const int mod = 1e9 + 7;
const long long LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI =
    3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  int af = a.first, as = a.second;
  int bf = b.first, bs = b.second;
  if (as > 0 and bs > 0) {
    return af < bf;
  } else if (as > 0 and bs <= 0) {
    return true;
  } else if (as <= 0 and bs > 0) {
    return false;
  } else {
    return max(af, bf - as) < max(bf, af - bs);
  }
}
int dp[110][60500] = {};
signed main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(12);
  int n, r;
  cin >> n >> r;
  vector<pair<int, int> > pr;
  for (int i = (0); i < (n); ++i) {
    int a, b;
    cin >> a >> b;
    pr.emplace_back(a, b);
  }
  sort(pr.begin(), pr.end(), cmp);
  for (int i = (0); i < (110); ++i)
    for (int j = (0); j < (60500); ++j) dp[i][j] = -INF;
  dp[0][r] = 0;
  for (int i = (0); i < (n); ++i) {
    int a, b;
    tie(a, b) = pr[i];
    for (int j = (0); j < (60500); ++j) {
      if (j - b < 0 or j - b >= 60500) {
        dp[i + 1][j] = dp[i][j];
      } else {
        if (j - b >= a)
          dp[i + 1][j] = max(dp[i][j], dp[i][j - b] + 1);
        else
          dp[i + 1][j] = dp[i][j];
      }
    }
  }
  int ans = 0;
  for (int i = (0); i < (60500); ++i) {
    if (dp[n][i] >= 1) chmax(ans, dp[n][i]);
  }
  cout << ans << endl;
}
