#include <bits/stdc++.h>
using namespace std;
int n, r;
vector<pair<int, int> > pos, neg;
int sz;
int dp[105][60005];
bool comp(const pair<int, int> &p1, const pair<int, int> &p2) {
  return (p1.first + p1.second) > (p2.first + p2.second);
}
int solve(int idx, int curr) {
  if (idx == sz) {
    return 0;
  }
  if (dp[idx][curr] != -1) {
    return dp[idx][curr];
  }
  int val = solve(idx + 1, curr);
  if (curr >= neg[idx].first && (curr + neg[idx].second) >= 0) {
    val = max(val, 1 + solve(idx + 1, curr + neg[idx].second));
  }
  return dp[idx][curr] = val;
}
int main() {
  scanf("%d %d", &n, &r);
  for (int i = 1; i <= n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (b >= 0) {
      pos.push_back({a, b});
    } else {
      neg.push_back({a, b});
    }
  }
  sort(pos.begin(), pos.end());
  sort(neg.begin(), neg.end(), comp);
  int ans = 0;
  for (auto it : pos) {
    if (r >= it.first) {
      r += it.second;
      ans += 1;
    } else {
      break;
    }
  }
  sz = (int)neg.size();
  memset(dp, -1, sizeof(dp));
  ans += solve(0, r);
  printf("%d", ans);
  return 0;
}
