//This is getting accepted!
#include<bits/stdc++.h>
#define ll long long
#define oo 1000000009
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define INA(a,n) for (int i = 1; i <= (n); ++i) cin >> a[i];
#define ITE(x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define isset(x, i) (((x)>>(i))&1)
#define setbit(x, i) ((x)^(1ll<<(i)))
#define clearbit(x, i) ((x)&(~(1ll<<(i))))
#define twoexp(i) (1ll<<(i))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) >= 0 ? (a) : -(a))
#define FI first
#define SE second
#define son1 (id*2)
#define son2 (id*2+1)

using namespace std;

template<class T> using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;

const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = 2 * acos(0);
const int MAXN = 1e6 + 6;

int n, m;
int S, T;

struct Dijkstra 
	{
		// NOTE: zero-based or one-based vertex indexes are both acceptable
		// DIRECTIONAL - graph
		
		struct Edge {
			int u, v, w;
			
			Edge(int u_, int v_, int w_) {
				u = u_; v = v_; w = w_;
			}
		};
		
		int n, m;
		vector<int> *adj;
		vector<Edge> edges;
	//	int edge_cnt;
		
		ll *dist;
		int *prev;
		ll INF;
		
		void init(int n_, int m_) {
			n = n_;
			m = m_;
			
			adj = new vector<int>[n+1];
			edges.clear();
	//		edge_cnt = 0;
			
			dist = new ll[n+1];
			prev = new int[n+1];
			
			INF = 1ll * oo * oo;
		}
		
		void addEdge(int u, int v, int w) {
			Edge e(u, v, w);
			edges.push_back(e);
			adj[u].push_back(edges.size()-1);
	//		edges[edge_cnt] = e;
	//		adj[u].push_back(edge_cnt++);
		}
		
		pair<vector<int>, ll> findShortestPath(int start, int end) {
			fill(dist, dist + n + 1, INF);
			fill(prev, prev + n + 1, -1);
			dist[start] = 0;
			
			min_heap< pair<ll, int> > que;
			que.push(make_pair(0ll, start));
			
			while(!que.empty()) {
				pair<ll, int> top = que.top();
				que.pop();
				
				ll d = top.first;
				int u = top.second;
				
				if (d > dist[u])
					continue;
				
				if (u == end) {
					break;
				}
				
				for (int ie: adj[u]) {
					int v = edges[ie].v;
					int w = edges[ie].w;
									
					if (dist[v] > dist[u] + w) {
						dist[v] = dist[u] + w;
						prev[v] = u;
						que.push(make_pair(dist[v], v));
	//					cout << "from " << u << ", update dist " << v << " to " << dist[v] << endl;
					}
				}
			}
			
			vector<int> path;
			
			if (dist[end] == INF)
				return make_pair(path, INF);
			
			int u = end;
			while(u != -1) {
				path.push_back(u);
				u = prev[u];
			}
			reverse(path.begin(), path.end());
			
			return make_pair(path, dist[end]);
		}
		
	};

Dijkstra dijkstra;

void input() {
	int u, v, w, x, y, qtype;
	
	cin >> n >> m;
	
	dijkstra.init(n*3, m*3);
	
	FOR(i, 1, m) {
		cin >> x >> y;
		dijkstra.addEdge(x, y+n, 1);
		dijkstra.addEdge(x+n, y+n+n, 1);
		dijkstra.addEdge(x+n+n, y, 1);
	}
	
	cin >> S >> T;
	
}


void preprocess() {
	
	
	
}

void process(int itest) {
	int u, v, w, x, y, qtype;
	
	pair< vector<int>, ll> res = dijkstra.findShortestPath(S, T);
	
	if (res.second < oo) {
		cout << res.second / 3 << endl;
	}
	else 
		cout << -1 << endl;
	
}

void oneTest() {
	
	input();
	preprocess();
	process(0);
	
}

void multiTest() {
	
	int t;
	cin >> t;
	
	for (int it = 1; it <= t; ++it) {
		input();
		preprocess();
		process(it);
	}
}

int main(){
    #ifndef ONLINE_JUDGE
//    freopen("../out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	oneTest();
//	multiTest();

    return 0;

}


Measured memory_bytes: 28716