#include <bits/stdc++.h>
template <class T>
void rd(T &x) {
  x = 0;
  int f = 1;
  char c;
  while (!isdigit(c = getchar()))
    if (c == '-') f = -1;
  do {
    x = (x << 3) + (x << 1) + (c ^ 48);
  } while (isdigit(c = getchar()));
  x *= f;
}
namespace matrix {
const int N = 105, mod = 1e9 + 7;
struct matrix {
  int a[N][N], n, m;
  matrix() {}
  matrix(int x, int y) {
    n = x;
    m = y;
    memset(a, 0, sizeof a);
  }
  void clear() { memset(a, 0, sizeof a); }
  matrix operator*(matrix x) {
    matrix res(n, x.m);
    for (int i = 1; i <= n; i++)
      for (int k = 1; k <= m; k++)
        for (int j = 1; j <= x.m; j++)
          res.a[i][j] = (res.a[i][j] + 1ll * a[i][k] * x.a[k][j]) % mod;
    return res;
  }
  template <class T>
  matrix operator^(T b) {
    matrix res(n, m), x = *this;
    for (int i = 1; i <= res.n; i++) res.a[i][i] = 1;
    while (b) {
      if (b & 1) res = res * x;
      x = x * x;
      b >>= 1;
    }
    return res;
  }
};
}  // namespace matrix
using namespace std;
const int N = 105;
pair<int, int> a[N], b[N];
bool cmp1(pair<int, int> &x, pair<int, int> &y) {
  return x.first == y.first ? x.second > y.second : x.first < y.first;
}
bool cmp2(pair<int, int> &x, pair<int, int> &y) {
  return x.first + x.second == y.first + y.second
             ? x.second > y.second
             : x.first + x.second > y.first + y.second;
}
int n, r, t1, t2, dp[60005], ans = -1;
int main() {
  rd(n), rd(r);
  for (int i = 1, x, y; i <= n; i++)
    rd(x), rd(y), y < 0 ? b[++t2] = {x, y} : a[++t1] = {x, y};
  int k = t1;
  sort(a + 1, a + t1 + 1, cmp1);
  sort(b + 1, b + t2 + 1, cmp2);
  memset(dp, -1, sizeof dp);
  dp[r] = 0;
  for (int i = 1; i <= t1; i++)
    for (int j = 60000; j >= a[i].first; j--)
      if (dp[j] != -1)
        dp[j + a[i].second] = max(dp[j] + 1, dp[j + a[i].second]);
  for (int i = 1; i <= t2; i++)
    for (int j = b[i].first; j <= 60000; j++)
      if (dp[j] != -1 && j + b[i].second >= 0)
        dp[j + b[i].second] = max(dp[j] + 1, dp[j + b[i].second]);
  for (int i = 0; i <= 60000; i++) ans = max(dp[i], ans);
  printf("%d", ans);
  return 0;
}
