// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define ll long long

const int maxn=2e5+5;

vector<int>E[maxn];

int d[maxn][3]; // mod 3=j

int vis[maxn][3];

void bfs(int x)

{

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

    {

        for(int j=0;j<3;j++)

        {

            d[i][j]=1e9;

        }

    }

    queue<pair<int,int>>q;

    d[x][0]=0;

    vis[x][0]=1;

    q.push({x,0});

    while(!q.empty())

    {

        int now=q.front().first;

        int t=q.front().second;//这一步mod3的值

        int y=(t+1)%3;//下一步mod3的值

        q.pop();

        for(auto&v:E[now])

        {

            if(vis[v][y]) continue;

            vis[v][y]=1;

            d[v][y]=d[now][t]+1;

            q.push({v,y});

        }

    }



}

void dijkstra(int x)

{



}

int main()

{

   ios::sync_with_stdio(false);

   cin.tie(0);

   int n,m;

   cin>>n>>m;

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

   {

       int u,v;

       cin>>u>>v;

       E[u].push_back(v);

   }

   int s,t;

   cin>>s>>t;

   bfs(s);

   if(d[t][0]==1e9)

   {

       cout<<-1<<'\n';

   }

   else

    cout<<d[t][0]/3<<'\n';







}




















// Faster C++ solution for the same problem (measured speedup: 1.396548976946384x):
#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;

}