// 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.848925433464995x):
#include<bits/stdc++.h>

using namespace std;

#define int long long

#define ar array

const int mxn=1e5+3,INF=1e18;

int n,m;

vector<int> g[mxn];

int vis[mxn][3];

int s,t;

signed main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    cin>>n>>m;

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

    {

        int u,v;

        cin>>u>>v;

        g[u].push_back(v);

       // g[v].push_back(u);

    }

    cin>>s>>t;

   // for (int i=1;i<=n;i++) vis[i][0]=vis[i][1]=vis[i][2]=-1;

    queue<ar<int,2>> q;

    q.push({s,0});

    vis[s][0]=0;

    while(!q.empty())

    {

        int u=q.front()[0],time=q.front()[1];

        q.pop();

        for (int v : g[u])

        if (!vis[v][(time+1)%3])

        {

            vis[v][(time+1)%3]=vis[u][time]+1;

            q.push({v,(time+1)%3});

        }

    }

    if (vis[t][0]) cout<<vis[t][0]/3;

    else cout<<-1;

}