#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,ssse3,sse3,sse4,popcnt,avx,mmx,abm,tune=native")
using namespace std;
const int MM = 3e6 + 6;
int n, r, i, x, y, dp[MM], ans, ans2;
vector<pair<int, int> > a, b;
int main() {
  for (scanf("%d%d", &n, &r), i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    if (y >= 0)
      a.push_back({x, y});
    else
      b.push_back({x, y});
  }
  sort(a.begin(), a.end(),
       [](pair<int, int> i, pair<int, int> j) { return i.first < j.first; });
  sort(b.begin(), b.end(), [](pair<int, int> i, pair<int, int> j) {
    return i.first + i.second > j.first + j.second;
  });
  for (auto v : a) {
    if (v.first <= r) r += v.second, ans++;
  }
  for (auto v : b) {
    for (i = max(0, v.first + v.second); i <= r + v.second; i++)
      dp[i] = max(dp[i], dp[i - v.second] + 1);
  }
  for (i = 0; i <= r; i++) ans2 = max(ans2, dp[i]);
  printf("%d\n", ans + ans2);
  return 0;
}
