#include <bits/stdc++.h>
using namespace std;
bool comp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.second >= 0 && b.second >= 0) return a.first < b.first;
  if (a.second >= 0 && b.second < 0) return 1;
  if (a.second < 0 && b.second >= 0) return 0;
  return a.first + a.second > b.first + b.second;
}
long long func(long long, long long);
long long n, r;
int dp[102][600005];
pair<long long, long long> ar[105];
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> n >> r;
  for (int i = 0; i < n; i++) cin >> ar[i].first >> ar[i].second;
  sort(ar, ar + n, comp);
  cout << func(0, r);
}
long long func(long long idx, long long p) {
  if (p < 0) return -0x3f3f3f3f3f3f3f3f;
  if (idx == n) return 0;
  if (dp[idx][p] != -1) return dp[idx][p];
  return dp[idx][p] = max(
             func(idx + 1, p),
             (p >= ar[idx].first ? func(idx + 1, p + ar[idx].second) + 1 : 0));
}
