#include <bits/stdc++.h>
using namespace std;
long long n, r, a, b, c;
int dp[105][60005];
vector<pair<long long, long long> > pos;
vector<pair<long long, pair<long long, long long> > > neg;
int solve(int i, long long sum) {
  if (i == neg.size()) return 0;
  if (~dp[i][sum]) return dp[i][sum];
  int ans = solve(i + 1, sum);
  if (sum >= neg[i].second.first && sum + neg[i].second.second >= 0)
    ans = max(ans, solve(i + 1, sum + neg[i].second.second) + 1);
  return dp[i][sum] = ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(dp, -1, sizeof dp);
  cin >> n >> r;
  while (n--) {
    cin >> a >> b;
    if (b >= 0)
      pos.push_back({a, b});
    else
      neg.push_back({a + b, {a, b}});
  }
  sort(pos.begin(), pos.end());
  sort(neg.rbegin(), neg.rend());
  for (auto it : pos)
    if (r >= it.first) r += it.second, ++c;
  cout << c + solve(0, r);
  return 0;
}
