#include<iostream> 
#include<algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring> 
using namespace std;
const int N=1e5+10;
const int INF=1e9;
int n,m,s,t,dis[N][3];
vector<int> G[N];
void bfs(){
	memset(dis,-1,sizeof(dis));
	dis[s][0]=0;
	queue<pair<int,int> >que;
	que.push({s,0});
	while(!que.empty()){
		pair<int,int> u=que.front();que.pop();
		for(int i=0;i < G[u.first].size();i++){
			if(dis[G[u.first][i]][(u.second+1)%3]<0){
				dis[G[u.first][i]][(u.second+1)%3]=dis[u.first][u.second]+1;
				que.push({G[u.first][i],(u.second+1)%3});
			}
		}
	}
	
}
int main(){
	cin>>n>>m;
	int u,v;
	while(m--){
		cin>>u>>v;
		G[u].push_back(v);
	}
	cin>>s>>t;
	bfs();
	if(dis[t][0]==-1)puts("-1");
	else cout<<dis[t][0]/3<<endl;
	return 0;
}
