#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int,int> P;
int N,M,S,T;
int dp[100010][3] = {};
int inf = 1e9;
vector<vector<int>> v(100010);

int main(){
    cin >> N >> M;
    int a,b;
    for(int i=0;i<M;i++){
        cin >> a >> b;
        v[a].push_back(b);
    }
    cin >> S >> T;
    for(int i=1;i<=N;i++) for(int j=0;j<=2;j++) dp[i][j] = inf;
    dp[S][0] = 0;
    queue<P> Q;
    Q.push({S,0});
    while(!Q.empty()){
        P p = Q.front(); Q.pop();
        for(auto x:v[p.first]){
            int ne = (p.second+1)%3;
            if(dp[x][ne]==inf){
                dp[x][ne] = dp[p.first][p.second]+1;
                Q.push({x,ne});
            }
        }
    }
    cout << (dp[T][0]!=inf? dp[T][0]/3:-1) << endl;
}