#include <bits/stdc++.h>
using namespace std;
int dp[105][30005 << 1], n, r;
struct Node {
  int a, b;
} c[105], d[105];
int cmp(Node a, Node b) { return a.a + a.b > b.a + b.b; }
int cnt1, cnt2, vis[30005];
int main() {
  cin >> n >> r;
  for (int i = 1; i <= n; i++) {
    int a, b;
    cin >> a >> b;
    if (b > 0) {
      cnt1++;
      c[cnt1].a = a, c[cnt1].b = b;
    } else {
      cnt2++;
      d[cnt2].a = a, d[cnt2].b = b;
    }
  }
  int tot = 0;
  for (int i = 1; i <= cnt1; i++)
    for (int j = 1; j <= cnt1; j++)
      if (!vis[j] && r >= c[j].a) {
        r += c[j].b;
        vis[j] = 1;
        tot++;
        break;
      }
  sort(d + 1, d + 1 + cnt2, cmp);
  memset(dp, -0x3f, sizeof dp);
  dp[0][r] = tot;
  for (int i = 1; i <= cnt2; i++)
    for (int j = 0; j <= r; j++) {
      if (dp[i - 1][j] >= 0) dp[i][j] = dp[i - 1][j];
      if (j - d[i].b >= d[i].a && dp[i - 1][j - d[i].b] >= 0)
        dp[i][j] = max(dp[i][j], dp[i - 1][j - d[i].b] + 1);
    }
  int ans = 0;
  for (int j = r; j >= 0; j--)
    if (dp[cnt2][j] >= 0) ans = max(ans, dp[cnt2][j]);
  cout << ans << endl;
}
