#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxm = 2e5 + 10;
int dp[105][60005];
struct node {
  int a, b;
} pos[200], neg[200], tot[200];
bool cmp1(node n1, node n2) { return n1.a < n2.a; }
bool cmp2(node n1, node n2) { return (n1.a + n1.b) < (n2.a + n2.b); }
int main() {
  int n, r, flag = 0, ans = 0;
  scanf("%d%d", &n, &r);
  int temp1 = 0, temp2 = 0;
  for (int i = 1; i <= n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (b >= 0) {
      pos[++temp1].a = a;
      pos[temp1].b = b;
    } else {
      neg[++temp2].a = a;
      neg[temp2].b = b;
    }
  }
  sort(pos + 1, pos + temp1 + 1, cmp1);
  sort(neg + 1, neg + temp2 + 1, cmp2);
  for (int i = 1; i <= temp1; i++) {
    if (r >= pos[i].a) {
      r += pos[i].b;
      ans++;
    }
  }
  for (int i = 0; i <= r; i++) {
    if (i >= neg[1].a && i >= -neg[1].b)
      dp[1][i] = 1;
    else
      dp[1][i] = 0;
  }
  for (int i = 2; i <= temp2; i++) {
    for (int j = 0; j <= r; j++) {
      if (j >= neg[i].a && j >= -neg[i].b) {
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j + neg[i].b] + 1);
      } else
        dp[i][j] = dp[i - 1][j];
    }
  }
  ans += dp[temp2][r];
  printf("%d\n", ans);
  return 0;
}
