#include <bits/stdc++.h>
using namespace std;
int need(pair<int, int> a, pair<int, int> b) {
  int ret = a.first;
  int have = ret + a.second;
  int add;
  add = max(0, b.first - have);
  have += add;
  ret += add;
  have += b.second;
  if (have < 0) {
    add = abs(have);
    have += add;
    ret += add;
  }
  return ret;
}
bool cmp(pair<int, int> a, pair<int, int> b) {
  int ab = need(a, b), ba = need(b, a);
  if (ab != ba) return ab < ba;
  if (a.first != b.first) return a.first > b.first;
  return a.second < b.second;
}
const int N = 102;
const int R = 30002;
const int A = 302;
const int MX = R + N * A;
short dp[N][MX];
bool vis[N][MX];
vector<pair<int, int> > pos, neg;
short solve(int idx, int r) {
  if (r < 0) return -N;
  if (idx == int(neg.size())) return 0;
  short &ret = dp[idx][r];
  if (vis[idx][r]) return ret;
  vis[idx][r] = true;
  ret = solve(idx + 1, r);
  if (r >= neg[idx].first) {
    short cur = solve(idx + 1, r + neg[idx].second) + 1;
    ret = max(ret, cur);
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, r;
  cin >> n >> r;
  vector<pair<int, int> > v(n);
  for (int i = 0; i < int(n); i++) {
    cin >> v[i].first >> v[i].second;
    if (v[i].second >= 0)
      pos.push_back(v[i]);
    else
      neg.push_back(v[i]);
  }
  sort(pos.begin(), pos.end());
  sort(neg.begin(), neg.end(), cmp);
  int ans = 0;
  for (int i = 0; i < int(int(pos.size())); i++) {
    if (r < pos[i].first) continue;
    ans++;
    r += pos[i].second;
  }
  ans += solve(0, r);
  cout << ans << '\n';
  return 0;
}
