#include<algorithm>
using namespace std;
const int N = 1e3 + 10;
#define x first
#define y second
pair<int,int> a[N];
int b[N];
int cmp(pair<int,int>a, pair<int,int>b)
{
if(a.x + a.y != b.x + b.y)return a.x + a.y < b.x + b.y;
else {
return a.x > b.x;
}
}
int main()
{
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; i ++)
{
cin >> a[i].x >> a[i].y;
}
int mx = 0;
sort(a + 1, a + 1 + n,cmp);
int r = m;
for(int u = 1; u <= n; u ++)
{
int cnt = 0;
m = r;
for(int i = 1; i <= n; i ++)
{
if(i == u)
{
if(a[i].x / 2 + a[i].y <= m)
{
m -= (a[i].x / 2 + a[i].y);
cnt ++;
}
}
else if(a[i].x + a[i].y <= m)
{
m -= (a[i].x + a[i].y);
cnt ++;
}
}
mx = max(cnt, mx);
}
cout << mx <<endl;
}