#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

const int Maxn = 100005;
int n, m, st, ed;
int dist[Maxn][3];
vector <int> g[Maxn];

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; ++ i) {
		int u, v;
		scanf("%d %d", &u, &v);
		g[u].push_back(v);
	}
	scanf("%d %d", &st, &ed);
	queue <pair <int, int> > que;
	que.push({st, 0});
	memset(dist, 0x3f, sizeof (dist));
	dist[st][0] = 0;
	while (!que.empty()) {
		int u = que.front().first;
		int d = que.front().second;
		que.pop();
		for (auto &v: g[u])
			if (dist[v][(d + 1) % 3] > dist[u][d] + 1) {
				dist[v][(d + 1) % 3] = dist[u][d] + 1;
				que.push({v, (d + 1) % 3});
			}
	}
	if (dist[ed][0] < 0x3f3f3f3f)
		printf("%d\n", dist[ed][0] / 3);
	else
		puts("-1");
	return 0;
}