program prisonbreak;
var
a,b:array[0..10000] of longint;
f:array[0..10000] of longint;
n,i,j:longint;
bool:boolean;
procedure sort(l,r:longint);
var
i,j,x,y:longint;
begin
i:=l; j:=r;
x:=a[(l+r) div 2];
repeat
while a[i]<x do inc(i);
while x<a[j] do dec(j);
if not(i>j) then
begin
y:=a[i]; a[i]:=a[j]; a[j]:=y;
y:=b[i]; b[i]:=b[j]; b[j]:=y;
i:=i+1; j:=j-1;
end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end;
begin
assign(input,'prisonbreak.in');
reset(input);
assign(output,'prisonbreak.out');
rewrite(output);
readln(n);
for i:=1 to n do
readln(a[i],b[i]);
readln(a[0],b[0]);
for i:=1 to n do
a[i]:=a[0]-a[i];
sort(1,n);
fillchar(f,sizeof(f),0);
f[0]:=b[0];
for i:=1 to n do
for j:=i downto 1 do
if f[j-1]>=a[i] then
begin
if f[j-1]+b[i]>f[j]
then f[j]:=f[j-1]+b[i]
end
else break;
bool:=true;
for i:=0 to n do
if f[i]>=a[0] then
begin
writeln(i);
bool:=false;
break
end;
if bool then writeln(-1);
close(input);
close(output);
end.