#include<bits/stdc++.h>
#define N 100005
#define MO 1000000007
using namespace std;
int n,m,K,st,ed;
int dp[N][3];
vector<int>P[N];
struct node {
	int a,b,c;
};
void spfa(){
	memset(dp,0x3f,sizeof(dp));
	queue<node>Q;
	Q.push((node){st,0,0});
	dp[st][0]=0;
	while(!Q.empty()){
		node x=Q.front();
		Q.pop();
		if(dp[x.a][x.b]<x.c)continue;
		for(int i=0;i<P[x.a].size();i++){
			int a=P[x.a][i],b=(x.b+1)%3,c=x.c+(x.b+1)/3;
			if(dp[a][b]>c){
				dp[a][b]=c;
				Q.push((node){a,b,c});
			}
		}
	}
}
void solve(){
	scanf("%d %d",&n,&m);
	for(int a,b,i=1;i<=m;i++){
		scanf("%d %d",&a,&b);
		P[a].push_back(b);
	}
	scanf("%d %d",&st,&ed);
	spfa();
	if(dp[ed][0]==0x3f3f3f3f)dp[ed][0]=-1;
	printf("%d\n",dp[ed][0]);
}
int main(){
	solve();
	return 0;
}