#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#define max 10010
using namespace std;
#include<cstdio>
#include<algorithm>
#include<queue>
#define max 10010
using namespace std;
struct node
{
int dist,fuel;
};
node position[max];
{
int dist,fuel;
};
node position[max];
int n,L,P;
bool cmp(const node &a,const node &b)
{
return a.dist > b.dist;
}
{
return a.dist > b.dist;
}
int main()
{
while(scanf("%d",&n) != EOF)
{
priority_queue<int> heap;
for(int i = 0;i < n;i++)
scanf("%d %d",&position[i].dist,&position[i].fuel);
sort(position,position+n,cmp);
scanf("%d %d",&L,&P);
int t = 0;
heap.push(P);
int index = 0;
while(L > 0 && !heap.empty())
{
t++;
int tmp = heap.top();
heap.pop();
L -= tmp;
while(index < n && L <= position[index].dist)
heap.push(position[index++].dist);
}
printf("%d\n",L <= 0 ? t - 1: -1);
}
return 0;
}
{
while(scanf("%d",&n) != EOF)
{
priority_queue<int> heap;
for(int i = 0;i < n;i++)
scanf("%d %d",&position[i].dist,&position[i].fuel);
sort(position,position+n,cmp);
scanf("%d %d",&L,&P);
int t = 0;
heap.push(P);
int index = 0;
while(L > 0 && !heap.empty())
{
t++;
int tmp = heap.top();
heap.pop();
L -= tmp;
while(index < n && L <= position[index].dist)
heap.push(position[index++].dist);
}
printf("%d\n",L <= 0 ? t - 1: -1);
}
return 0;
}