#include <bits/stdc++.h>
using namespace std;
int read() {
  int xx = 0, ff = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    xx = xx * 10 + ch - '0';
    ch = getchar();
  }
  return xx * ff;
}
long long READ() {
  long long xx = 0, ff = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    xx = xx * 10 + ch - '0';
    ch = getchar();
  }
  return xx * ff;
}
char one() {
  char ch = getchar();
  while (ch == ' ' || ch == '\n') ch = getchar();
  return ch;
}
const int maxn = 110;
int N, R, cnt;
struct proj {
  int a, b;
  bool friend operator<(const proj& A, const proj& B) {
    return A.a + A.b > B.a + B.b;
  }
} P[maxn], obj[maxn];
bool vis[maxn];
int f[maxn][maxn];
int main() {
  N = read(), R = read();
  for (int i = 1; i <= N; i++) P[i].a = read(), P[i].b = read();
  int ans = 0;
  while (1) {
    bool flag = 0;
    for (int i = 1; i <= N; i++)
      if (!vis[i] && R >= P[i].a && P[i].b >= 0) {
        flag = 1;
        vis[i] = 1;
        R += P[i].b;
        ans++;
      }
    if (!flag) break;
  }
  for (int i = 1; i <= N; i++)
    if (P[i].b < 0) obj[++cnt] = P[i];
  memset(f, -1, sizeof(f));
  sort(obj + 1, obj + 1 + cnt);
  f[0][0] = R;
  for (int i = 1; i <= cnt; i++) {
    for (int j = 0; j <= i; j++) {
      f[i][j] = f[i - 1][j];
      if (j && f[i - 1][j - 1] >= obj[i].a)
        f[i][j] = max(f[i][j], f[i - 1][j - 1] + obj[i].b);
    }
  }
  int mx = 0;
  for (int i = 1; i <= cnt; i++)
    for (int j = 0; j <= cnt; j++)
      if (f[i][j] != -1) mx = max(mx, j);
  printf("%d\n", mx + ans);
  return 0;
}
