#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,m,h[N],w[N],g[N],x,y,s,t;
struct E{
	int l,to;
}e[N];
struct P{
	int d,w;
};
queue<P>Q;
int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;++i){
		scanf("%d %d",&x,&y);
		e[i].to=y;
		e[i].l=h[x];
		h[x]=i;
	}
	scanf("%d %d",&s,&t);
	w[s]=1;
	Q.push({s,0});
	while(!Q.empty()){
		P k=Q.front();Q.pop();
		bool fl= (k.w%3)==2;
//		printf("%d %d %d\n",k.d,k.w,fl);
		for(int i=h[k.d];i;i=e[i].l){
			if(fl){
				if(!w[e[i].to]){
					w[e[i].to]=k.w/3+1;
					Q.push({e[i].to,k.w+1});
				}
			}
			else {
				if(g[e[i].to]!=k.w+1){
					g[e[i].to]=k.w+1;
					Q.push({e[i].to,k.w+1});
				}
			}
		}
		if(w[t])break;
	}
	if(!w[t])w[t]=-1;
	printf("%d",w[t]);
}