#include <bits/stdc++.h>
using namespace std;
template <typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
  for (Tp current = _begin; current != _end; ++current) {
    std::cout << *current << _delim;
  }
  std::cout << '\n';
}
using ll = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);
pii arr[100];
bool used[100];
vector<pii> vec;
int dp[60001];
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, r;
  cin >> n >> r;
  for (int i = 0; i < (n); ++i) {
    cin >> arr[i].first >> arr[i].second;
  }
  sort(arr, arr + n);
  int ans = 0;
  for (;;) {
    int delta = -INF;
    int j = -1;
    for (int i = 0; i < (n); ++i) {
      if (arr[i].first > r) {
        break;
      }
      if (used[i]) {
        continue;
      }
      if (delta <= arr[i].second) {
        delta = arr[i].second;
        j = i;
      }
    }
    if (j == -1 || delta < 0) {
      break;
    }
    r += delta;
    used[j] = true;
    ++ans;
  }
  for (int i = 0; i < (n); ++i) {
    if (r < arr[i].first) {
      break;
    }
    if (used[i]) {
      continue;
    }
    vec.push_back(arr[i]);
  }
  sort(std::begin(vec), std::end(vec), [](const pii& a, const pii& b) {
    return a.first + a.second > b.first + b.second;
  });
  for (int i = 0; i < (static_cast<int>((vec).size())); ++i) {
    for (int j = max(-vec[i].second, vec[i].first); j <= r; ++j) {
      dp[j + vec[i].second] = max(dp[j] + 1, dp[j + vec[i].second]);
    }
  }
  ans += *max_element(dp, dp + r + 1);
  cout << ans << "\n";
  return 0;
}
