#include <bits/stdc++.h>
using namespace std;
const long long N = 1e7 + 10;
const int maxn = 100 + 5;
const int mod = 1;
struct node {
  int a, b;
} p1[maxn], p2[maxn];
int tot1 = 0, tot2 = 0;
bool cmp1(const node &a, const node &b) { return a.a < b.a; }
bool cmp2(const node &a, const node &b) {
  if (a.a - a.b == b.a - b.b) return a.b < b.b;
  return a.a - a.b > b.a - b.b;
}
int dp[maxn][maxn];
int main() {
  int n, r;
  scanf("%d %d", &n, &r);
  for (int i = 1; i <= n; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (b < 0)
      p2[++tot2].a = a, p2[tot2].b = -b;
    else
      p1[++tot1].a = a, p1[tot1].b = b;
  }
  sort(p1 + 1, p1 + 1 + tot1, cmp1);
  int ans = 0;
  for (int i = 1; i <= tot1; ++i) {
    if (r >= p1[i].a) {
      ans++;
      r += p1[i].b;
    } else
      break;
  }
  sort(p2 + 1, p2 + 1 + tot2, cmp2);
  memset(dp, -1, sizeof dp);
  dp[0][0] = r;
  for (int i = 1; i <= tot2; ++i) {
    dp[i][0] = r;
    for (int j = 1; j <= i; ++j) {
      if (dp[i - 1][j - 1] < p2[i].a)
        dp[i][j] = -1;
      else
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - 1] - p2[i].b);
    }
  }
  int res = 0;
  for (int i = 1; i <= tot2; ++i) {
    for (int j = 0; j <= i; ++j) {
      if (dp[i][j] >= 0) res = max(res, j);
    }
  }
  printf("%d\n", ans + res);
}
