#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int INF=1<<29;

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<int> G[100000];
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		G[u].emplace_back(v);
	}
	int s,t; scanf("%d%d",&s,&t); s--; t--;

	int d[100000][3];
	rep(u,n) rep(k,3) d[u][k]=INF;
	d[s][0]=0;
	priority_queue<tuple<int,int,int>> Q;
	Q.emplace(0,s,0);
	while(!Q.empty()){
		auto a=Q.top(); Q.pop();
		int d0=-get<0>(a),u=get<1>(a),k=get<2>(a);
		if(d0>d[u][k]) continue;

		if(u==t && k==0){ printf("%d\n",d0/3); return 0; }

		for(int v:G[u]){
			if(d[v][(k+1)%3]>d0+1){
				d[v][(k+1)%3]=d0+1;
				Q.emplace(-d[v][(k+1)%3],v,(k+1)%3);
			}
		}
	}

	puts("-1");

	return 0;
}
