#include <bits/stdc++.h>
using namespace std;
const int MX = 1e5+2;
vector<int> adj[MX];
int dist[MX][3];
struct info {
	int u, dep;
};
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n, m;
	cin >> n >> m;
	while(m--) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
	}
	int s, t;
	cin >> s >> t;
	memset(dist, 0x3f, sizeof dist);
	dist[s][0] = 0;
	queue<int> que;
	que.push(s);
	int d = 0, nxtd;
	while(que.size()) {
		int sz = que.size();
		nxtd = d == 2 ? 0 : d+1;
		while(sz--) {
			int q = que.front();
			que.pop();
			for(int a: adj[q]) {
				if(dist[q][d]+1 < dist[a][nxtd]) {
					dist[a][nxtd] = dist[q][d]+1;
					que.push(a);
				}
			}
		}
		d = nxtd;
	}
	cout << (dist[t][0] == 0x3f3f3f3f ? -1 : dist[t][0]/3);
}