{$M 400000000}
const maxn = 10000;
fi = '';
fo = '';
type tqueue = record
front,rear,nitem:word;
item: array[0..maxn-1] of word;
end;
var n,s,t:word;
m:longint;
g: array[1..maxn,0..maxn] of word;
trace: array[1..maxn] of word;
queue: tqueue;
procedure enter;
var i:longint;
u,v:word;
begin
assign(input,fi);
reset(input);
readln(n,m,s,t);
for i:=1 to n do
g[i,0]:=0;
for i:=1 to m do
begin
readln(u,v);
inc(g[u,0]);
g[u,g[u,0]]:=v;
end;
close(input);
end;
procedure initq;
begin
with queue do
begin
front:=0;
rear:=1;
nitem:=0;
end;
end;
procedure push(v:word);
begin
with queue do
begin
inc(nitem);
front:=(front+1) mod maxn;
item[front]:=v;
end;
end;
function pop:word;
begin
with queue do
begin
dec(nitem);
pop:=item[rear];
rear:=(rear+1) mod maxn;
end;
end;
function empty:boolean;
begin
with queue do
empty:=(nitem=0);
end;
procedure printtrace;
var i:word;
begin
for i:=1 to n do
write(trace[i],' ');
writeln;
end;
procedure bfs;
var i,j:word;
visit: array[1..maxn] of boolean;
begin
initq;
fillchar(visit,sizeof(visit),false);
fillchar(trace,sizeof(trace),0);
push(s);
visit[s]:=true;
repeat
i:=pop;
for j:=1 to g[i,0] do
if not visit[g[i,j]] then
begin
push(g[i,j]);
visit[g[i,j]]:=true;
trace[g[i,j]]:=i;
if g[i,j]=t then exit;
end;
until empty;
end;
procedure solve;
var lock,res:word;
visit: array[1..maxn] of boolean;
function dfs(i:longint):boolean;
var j:longint;
p:boolean;
begin
visit[i]:=true;
if i=t then dfs:=true
else
if i=lock then dfs:=false
else
begin
p:=false;
for j:=1 to g[i,0] do
if not visit[g[i,j]] then
begin
p:=p or dfs(g[i,j]);
if p then break;
end;
dfs:=p;
end;
end;
begin
assign(output,fo);
rewrite(output);
bfs;
lock:=trace[t];
res:=0;
while (lock<>s) and (lock<>0) do
begin
fillchar(visit,sizeof(visit),false);
if not dfs(s) then inc(res);
lock:=trace[lock];
end;
writeln(res);
close(output);
end;
begin
enter;
solve;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