#include <bits/stdc++.h>
using namespace std;
long long t, n, i, j, k, x, y, z, l, r, mid, ans, mod = 1e9 + 7, g, m;
long long b[400005], c[400005], d[101][60005];
char ch;
string s, st;
vector<pair<long long, long long> > v[300004], u;
bool srt(pair<long long, long long> a, pair<long long, long long> b) {
  return a.first + a.second > b.first + b.second;
}
long long dp(int i, int x) {
  if (i == n) return 0;
  long long &ret = d[i][x];
  if (ret + 1) return ret;
  ret = dp(i + 1, x);
  if (v[0][i].first <= x) ret = max(ret, 1 + dp(i + 1, x + v[0][i].second));
  return ret;
}
int main() {
  ios::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
  memset(d, -1, sizeof d);
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    v[y >= 0].push_back({max(x, -y), y});
  }
  x = 0;
  sort(v[1].begin(), v[1].end());
  sort(v[0].begin(), v[0].end(), srt);
  for (auto i : v[1])
    if (i.first <= m) m += i.second, x++;
  n = v[0].size();
  x += dp(0, m);
  cout << x;
}
