Program city;
Type
abc=record
data:integer;
dep:integer;
end;
sc=array [1..100,1..100] of integer;
sc1=array [1..100] of abc;
sc2=array [1..100] of boolean;
Var
s:sc;
dui:sc1;
panduan:sc2;
head,tail:integer;
i,j:integer;
n,m,c,e,a,b:integer;
Begin
assign(input,'city.in');
assign(output,'city.out');
reset(input);
rewrite(output);
readln(n,m,c,e);
for i:=1 to n do
for j:=1 to n do
s[i,j]:=0;
for i:=1 to m do begin
readln(a,b);
s[a,b]:=1;
end;
head:=0; tail:=0;
dui[1].data:=c;
dui[1].dep:=1;
for i:=1 to n do panduan[i]:=true;
panduan[c]:=false;
head:=0; tail:=1;
repeat
head:=head+1;
for i:=1 to n do begin
if s[dui[head].data,i]=1 then begin
if panduan[i]=true then begin
tail:=tail+1;
dui[tail].data:=i;
dui[tail].dep:=dui[head].dep+1;
if dui[tail].data=e then begin
writeln(dui[tail].dep);
close(input);
close(output);
halt;
end;
panduan[i]:=false;
end;
end;
end;
until(head=tail);
End.