#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */
namespace utils{

    class Repeater{
        int st;
        int ed;
        int d;
    public:
        class rep_iterator{
            int i; int d;
        public:
            rep_iterator(int x, int pd) :i(x), d(pd) {}

            int& operator*(){ return i; }
            bool operator==(const rep_iterator& k) const { return i == k.i; }
            bool operator!=(const rep_iterator& k) const { return i != k.i; }
            rep_iterator& operator++(){ i+=d; return *this; }
        };

        explicit Repeater(int N) :st(0), ed(N), d(1) {}
        Repeater(int b, int e) :st(b), ed(e), d(1) {if(st > ed){ st--; ed--; d = -1; } }

        rep_iterator begin() const{ return rep_iterator(st, d); }
        rep_iterator end() const{ return rep_iterator(ed, d); }

    };

    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;

class Graph{
    unordered_map<int, unordered_set<int>> children;
    unordered_map<int, unordered_set<int>> d2v, d3v;
public:
    Graph() = default;

    void make_edge(int i, int j){
        // i -> j
        children[i].insert(j);
    }

    const unordered_set<int>& child(int v) {
        return children[v];
    }

    void make_d2(){
        for (auto &&c : children) {
            int v = c.first;
            for (auto &&u : c.second) {
                for (auto &&t : children[u]) {
                    d2v[v].insert(t);
                } // end t
            } // end u

        } // end c
    }
    void make_d3(){
        for (auto &&c : children) {
            int v = c.first;
            for (auto &&u : c.second) {
                for (auto &&t : d2v[u]) {
                    d3v[v].insert(t);
                } // end t
            } // end u
        } // end c
    }

    unordered_set<int> d3vertecies(int v){
        return d3v[v];
    }

};


void sub_main(istream &is) {
    ll N, M;
    is >> N >> M;
    if(!is) return;
    Graph initial;
    for (auto &&i : Repeater(0, M)) {
        int u, v;
        is >> u >> v;
        initial.make_edge(u, v);
    } // end i
    int S, T;
    is >> S >> T;



    array<vector<ll>, 3> ds;
    ds[0] = ds[1] = ds[2] = vector<ll>(N+1,INF);
    queue<pair<int, int>> bfq;
    bfq.emplace(S, 0);
    ds[0][S] = 0;
    while(!bfq.empty()){
        auto top = bfq.front(); bfq.pop();
        ll v = top.first;
        ll fase = (top.second + 1) % 3;
        ll d = ds[top.second][v] + 1;
        for (auto i : initial.child(v)) {
            if(min_update(ds[fase][i], d)){
                bfq.emplace(i, fase);
            }
        } // end i
    }
    cout << (ds[0][T] == INF ? -1 : ds[0][T] / 3) << endl;
}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_E.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


Measured memory_bytes: 17700