#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > pos, neg;
bool comp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first > b.first)
    return true;
  else if (a.first == b.first && a.second < b.second)
    return true;
  else
    return false;
}
bool comp2(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first + a.second > b.first + b.second)
    return true;
  else
    return false;
}
vector<pair<long long, long long> > total;
long long dp[109][70009];
long long solve(int id, int rating) {
  if (rating < 0) return -109;
  if (id >= total.size()) return 0;
  if (dp[id][rating] != -1) return dp[id][rating];
  if (total[id].first <= rating && rating + total[id].second >= 0)
    dp[id][rating] = max(solve(id + 1, rating),
                         solve(id + 1, rating + total[id].second) + 1);
  else
    dp[id][rating] = solve(id + 1, rating);
  return dp[id][rating];
}
int main() {
  ios::sync_with_stdio(false);
  memset(dp, -1, sizeof dp);
  long long n, c;
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    if (b >= 0) {
      pos.push_back({a, b});
    } else {
      neg.push_back({a, b});
    }
  }
  sort(pos.begin(), pos.end(), comp);
  sort(neg.begin(), neg.end(), comp2);
  reverse(pos.begin(), pos.end());
  for (auto e : pos) {
    total.push_back(e);
  }
  for (auto e : neg) {
    total.push_back(e);
  }
  cout << solve(0, c) << "\n";
  return 0;
}
