#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
const double dinf = inf;
long long qpow(long long a, long long b, long long mod) {
  long long ret = 1;
  for (; b; b >>= 1) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
  }
  return ret;
}
template <class T>
inline void read(T& x) {
  x = 0;
  char c = getchar();
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= c == '-';
  for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
  x = f ? -x : x;
}
template <class T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  T y = 1;
  int len = 1;
  for (; y <= x / 10; y *= 10) ++len;
  for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}
const int N = 100 + 10;
const int M = 6e4 + 10;
const int mod = (int)1e9 + 7;
const double eps = 1e-10;
const double pi = acos(-1.0);
vector<pair<int, int> > a, b;
int dp[M];
inline bool cmp(const pair<int, int>& A, const pair<int, int>& B) {
  return A.first + A.second > B.first + B.second;
}
int main() {
  int n, r, cnt = 0;
  cin >> n >> r;
  for (int i = 1; i <= (n); i++) {
    int x, y;
    cin >> x >> y;
    if (y >= 0)
      a.push_back(pair<int, int>(x, y));
    else
      b.push_back(pair<int, int>(max(x, -y), y));
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end(), cmp);
  for (pair<int, int>& t : a) {
    if (r >= t.first) r += t.second, cnt++;
  }
  for (int i = 0; i < ((int)b.size()); i++) {
    for (int j = b[i].first; j <= r; j++)
      dp[j + b[i].second] = max(dp[j + b[i].second], dp[j] + 1);
  }
  int ans = 0;
  for (int i = 0; i < (r + 1); i++) ans = max(ans, dp[i]);
  printf("%d\n", ans + cnt);
  return 0;
}
