// Slower C++ solution:
#include<iostream>

#include<bits/stdc++.h>

#include <stdio.h>

#include<unordered_map>

#define Amr_Abdelazim ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define ll long long

#define ld long double

#define pll pair<ll,ll>

#define vll vector<ll>

#define vvll vector<vector<ll> >

#define vpll vector<pair<ll,ll> >

#define P complex<ld>

#define X real()

#define Y imag()

#define all(v) v.begin(),v.end()

#define rall(v) v.rbegin(),v.rend()

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

#define repp(i,s,n)   for(int i=s;i<=n;i++)

#define print(v) {for(auto i:v)cout<<i<<" ";cout<<"\n";}

#define mkp make_pair

#define clr(ar,v) memset(ar,v,sizeof(ar));

#define TC ll amr_abdelazim;cin>>amr_abdelazim;while(amr_abdelazim--)

#define popcnt(x) __builtin_popcount(x)

#define EPS 1e-9

#define INF 1000000000000000009

using namespace std;

//freopen("output.txt", "w", stdout);

//freopen("input.txt", "r", stdin);

const int mod = 1000000007;

const int N = 2 * 100000 + 9;

const double pi = acos(-1);

class cmp{

public:

	bool operator() (ll &A, ll &B){

		return A > B;

	}

};

bool by_sec(const pll &a, const pll &b){

	if ((abs(a.first) == abs(b.first)))

		return (abs(a.second) < abs(b.second));

	return (abs(a.first) < abs(b.first));

}

bool byth(const tuple<ll, ll, ld>& a, const tuple<ll, ll, ld>& b){

	return (get<2>(a) < get<2>(b));

}

ld dist(P a, P b){

	return (ld)abs(a - b);

}

ll fact[1000009], inv[1000009];

ll fp(ll a, ll b){

	if (b == 0)

		return 1;

	ll ans = fp(a, b / 2);

	ans = (ans * ans) % mod;

	if (b % 2 != 0)

		ans = (ans * (a % mod)) % mod;

	return ans;

}

void FacInv(ll n){

	fact[0] = inv[0] = 1;

	for (ll i = 1; i <= n; i++)

	{

		fact[i] = ((i%mod) * fact[i - 1] % mod) % mod;

		inv[i] = fp(fact[i], mod - 2);

	}

}

ll ncr(ll n, ll r){

	return (((fact[n] * inv[r]) % mod) * inv[n - r]) % mod;

}

ll gcd(ll a, ll b){

	if (b == 0)return a;

	return gcd(b, a%b);

}

ll max(ll a, ll b){

	if (a >= b)return a;

	else return b;

}

ll min(ll a, ll b){

	if (a <= b)return a;

	else return b;

}



vvll gr(N);

bool vis[N][4];

vll en;

void dfs(ll n, ll c){

	vis[n][c] = 1;

	if (c == 0){

		if (!vis[n][3]){

			vis[n][3] = 1;

			en.push_back(n);

		}

		return;

	}

	for (auto i : gr[n]){

		if (!vis[i][c-1])

		dfs(i, c - 1);

	}

}



int main()

{

	Amr_Abdelazim



		ll n, m;

	cin >> n >> m;

	rep(i, m){

		ll a, b;

		cin >> a >> b;

		gr[a].push_back(b);

	}

	ll s, t;

	cin >> s >> t;

	dfs(s, 3);

	vis[s][3] = 1;

	ll lv = 1;

	bool bb = 1;

	while (bb){

		vll st = en;

		en.clear();

		bb = 0;

		for (auto i : st){

			if (i == t){

				cout << lv << "\n";

				return 0;

			}

			bb = 1;

			dfs(i, 3);

		}

		lv++;

	}

	cout << "-1\n";

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.6168294602740583x):
#include <iostream>

#include <algorithm>

#include <fstream>

#include <utility>

#include <iomanip>

#include <cstring>

#include <string>

#include <sstream>

#include <vector>

#include <queue>

#include <cmath>

#include <map>

#include <set>

#define IO ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

typedef long long ll;

typedef long double ld;



using namespace std;

const ll INF = 1e18;

const int mod = 1e9 + 7, N = 1e5 + 5, inf = 1e9;

int n, m, s, t, u, v;

vector<int>arr[N];



int bfs()

{

    queue<pair<int, int>>q;

    bool vis[N][5] = {};

    q.push({ s, 0 });

    vis[s][0] = true;

    while(q.size())

    {

        u = q.front().first;

        int ken = q.front().second;

        q.pop();



        if(u == t && ken % 3 == 0)

            return ken / 3;



        for(auto i : arr[u])

        {

            if(!vis[i][(ken + 1) % 3])

            {

                q.push({i, ken + 1});

                vis[i][(ken + 1) % 3] =true;

            }

        }

    }

    return -1;

}



int main()

{

    IO;

    cin >> n >> m;

    for(int i =0; i < m; i++)

    {

        cin >> u >> v;

        arr[u].push_back(v);

    }

    cin >> s >> t;

    cout << bfs() << '\n';

    return 0;

}