#include <algorithm>
#include <fstream>
using namespace std;
ifstream F("pitici3.in");
ofstream G("pitici3.out");
const int Nmax = 2010;
int N,H[Nmax],L[Nmax],oH[Nmax],oHL[Nmax];
int rev[Nmax],l[Nmax],D,h_init,co;
bool cmp1(int a,int b)
{
return H[a] == H[b] ? L[a] < L[b] : H[a] < H[b];
}
bool cmp2(int a,int b)
{
return H[a]+L[a] < H[b]+L[b];
}
bool good(int pitic)
{
int h_now = h_init - H[pitic];
l[ rev[pitic] ] = 1;
for (int i=N;i>=0;--i)
if ( l[i] == 1 )
{
if ( h_now + H[oHL[i]] + L[oHL[i]] >= D )
h_now += H[oHL[i]];
else
return 0;
}
return 1;
}
int main()
{
F>>N;
for (int i=1;i<=N;++i)
{
F>>H[i]>>L[i];
oH[i] = i;
oHL[i] = i;
}
F>>D;
sort(oH+1,oH+N+1,cmp1);
sort(oHL+1,oHL+N+1,cmp2);
for (int i=1;i<=N;++i)
{
rev[oHL[i]] = i;
h_init += H[i];
}
for (int i=1;i<=N;++i)
{
int pitic = oH[i];
if ( good(pitic) )
{
l[ rev[pitic] ] = 1;
h_init -= H[pitic];
co++;
}
else
l[ rev[pitic] ] = 0;
}
G<<co<<'\n';
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGZzdHJlYW0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppZnN0cmVhbSBGKCJwaXRpY2kzLmluIik7Cm9mc3RyZWFtIEcoInBpdGljaTMub3V0Iik7Cgpjb25zdCBpbnQgTm1heCA9IDIwMTA7CgppbnQgTixIW05tYXhdLExbTm1heF0sb0hbTm1heF0sb0hMW05tYXhdOwppbnQgcmV2W05tYXhdLGxbTm1heF0sRCxoX2luaXQsY287Cgpib29sIGNtcDEoaW50IGEsaW50IGIpCnsKICAgIHJldHVybiBIW2FdID09IEhbYl0gPyBMW2FdIDwgTFtiXSA6IEhbYV0gPCBIW2JdOwp9Cgpib29sIGNtcDIoaW50IGEsaW50IGIpCnsKICAgIHJldHVybiBIW2FdK0xbYV0gPCBIW2JdK0xbYl07Cn0KCmJvb2wgZ29vZChpbnQgcGl0aWMpCnsKICAgIGludCBoX25vdyA9IGhfaW5pdCAtIEhbcGl0aWNdOwogICAgbFsgcmV2W3BpdGljXSBdID0gMTsKICAgIGZvciAoaW50IGk9TjtpPj0wOy0taSkKICAgICAgICBpZiAoIGxbaV0gPT0gMSApCiAgICAgICAgewogICAgICAgICAgICBpZiAoIGhfbm93ICsgSFtvSExbaV1dICsgTFtvSExbaV1dID49IEQgKQogICAgICAgICAgICAgICAgaF9ub3cgKz0gSFtvSExbaV1dOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICByZXR1cm4gMDsKICAgICAgICB9CiAgICByZXR1cm4gMTsKfQoKaW50IG1haW4oKQp7CiAgICBGPj5OOwogICAgZm9yIChpbnQgaT0xO2k8PU47KytpKQogICAgewogICAgICAgIEY+PkhbaV0+PkxbaV07CiAgICAgICAgb0hbaV0gPSBpOwogICAgICAgIG9ITFtpXSA9IGk7CiAgICB9CiAgICBGPj5EOwogICAgc29ydChvSCsxLG9IK04rMSxjbXAxKTsKICAgIHNvcnQob0hMKzEsb0hMK04rMSxjbXAyKTsKICAgIGZvciAoaW50IGk9MTtpPD1OOysraSkKICAgIHsKICAgICAgICByZXZbb0hMW2ldXSA9IGk7CiAgICAgICAgaF9pbml0ICs9IEhbaV07CiAgICB9CiAgICBmb3IgKGludCBpPTE7aTw9TjsrK2kpCiAgICB7CiAgICAgICAgaW50IHBpdGljID0gb0hbaV07CiAgICAgICAgaWYgKCBnb29kKHBpdGljKSApCiAgICAgICAgewogICAgICAgICAgICBsWyByZXZbcGl0aWNdIF0gPSAxOwogICAgICAgICAgICBoX2luaXQgLT0gSFtwaXRpY107CiAgICAgICAgICAgIGNvKys7CiAgICAgICAgfQogICAgICAgIGVsc2UKICAgICAgICAgICAgbFsgcmV2W3BpdGljXSBdID0gMDsKICAgIH0KICAgIEc8PGNvPDwnXG4nOwp9