/*
Author: Arham_doshi
@quote "Apan isi back***di mai rehjayenge ,DA wale google lejayenge!"
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
#include <bits/stdc++.h>
using namespace std;
 
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
 
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> data_set; 
#define fbo find_by_order
#define ook order_of_key
 
 
 
 
#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define piiii       pair<pii,pii>
#define viiii       vector<pair<pii,pii>>
#define mi          map<int,int>
#define mii         map<pii,int>
#define piii           pair<int,pair<int,int> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define ef else if
 
 
 
 
 
int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}
 
int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}
 
int logb(int base, int x) {
    return (log(x) / log(base));
}
void set_max(int &mx,int x){if(mx==-1||mx<x)mx=x;}
 
 
int power(int x,  int y, int p) 
{ 
    int res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 
 
int mod_inv(int a,int m){
    a=a%m;
    return power(a,m-2,m)%MOD;
}
 
 
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
int fact[200005];
void count_fact(){
    int i,x=1;
    fact[0]=1;
    fo(i,1,200005){
        
        x=(x*i)%MOD;
      //  cout<<x<<" ";
        fact[i]=x;
        
    }
}
 
int ncr(int n,int r){
    int a=fact[n],b=fact[r],c=fact[n-r];
    
    return (a*mod_inv(b*c,MOD))%MOD;
   
}
 
 const int N=1e5+5;
 vi graph[N];
 int vis[N],dp[N][3];
 
 
 void dfs(int p){
     if(vis[p]!=-1)return ;
     vis[p]=1;
     
     for(int a : graph[p]){
         if(dp[p][2]!=-1&&(dp[a][0]==-1||(dp[a][0]>dp[p][2]+1))){
             dp[a][0]=dp[p][2]+1;
         }
         
         if(dp[p][0]!=-1&&(dp[a][1]==-1||(dp[a][1]>dp[p][0]+1))){
             dp[a][1]=dp[p][0]+1;
         }
         
         if(dp[p][1]!=-1&&(dp[a][2]==-1||(dp[a][2]>dp[p][1]+1))){
             dp[a][2]=dp[p][1]+1;
         }
         
         
         
         if(vis[a]==-1){
             dfs(a);
         }
         
     }
     
     
 }
 
 
 
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int i,j,x,n,m,a,b;
    cin>>n>>m;
    fo(i,0,m){
        cin>>a>>b;
        graph[a].pb(b);
        //cout<<a<<" "<<b<<endl;
    }
   /* fo(i,1,n+1){
        cout<<i<<" : ";
        for(int aa: graph[i]){cout<<aa<<" ";}
        cout<<endl;
    }
    */
    cin>>a>>b;
    _init(dp);
    dp[a][0]=0;
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
 
  dp[a][0]=0;
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
 
  dp[a][0]=0;
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
    
    
     dp[a][0]=0;
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
    
     dp[a][0]=0;
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
    
     dp[a][0]=0;
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
    
     dp[a][0]=0;
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
    
     dp[a][0]=0;
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
    
     dp[a][0]=0;
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
    _init(vis);
    dfs(a);
    
    
 
 
 
 
 
    if(dp[b][0]!=-1){
        cout<<dp[b][0]/3;
    }
    else{
        cout<<-1;
    }
    
    
    return 0;
}

Measured memory_bytes: 12672