#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;

int main() {
	int N, P; cin >> N >> P;
	vector<int> a(N + 1), b(N + 1);
	rep(i, N) cin >> a[i] >> b[i];
	a[N] = 0; b[N] = P + 1; N++;
	vector<vector<int> > dp(N + 1, vector<int>(N + 1, -1));
	dp[0][0] = P;
	rep(l, N) for (int r = l + 1; r <= N; r++) {
		int prev = 0;
		ll sum = 0;
		for (int i = l; i < r - 1; i++) {
			int x = max(0, a[i] - prev);
			int t = max(0, b[i] - x);
			prev = t;
			sum += t;
		}
		for (int x = 0; x + (r - l - 1) <= N; x++) {
			int _x = x + (r - l - 1);
			if (sum <= dp[l][x])
				dp[r][_x] = max((ll)dp[r][_x], dp[l][x] - sum);
		}
	}
	int ma = 0;
	for (int x = 0; x <= N; x++)
		if (dp[N][x] != -1)
			ma = max(ma, x);
	cout << ma << endl;
}