# Original solution
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(eval(input()))
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

########

class Edge:
    def __init__(self, from_edge, to_edge, cost):
        self.from_edge = from_edge
        self.to_edge = to_edge
        self.cost = cost

def bellman_ford(start, edges, node_num):
    dist = [INF] * node_num
    dist[start] = 0
    flag = False # 負の閉路の有無
    for i in range(node_num):
        for edge in edges:
            if dist[edge.to_edge] > dist[edge.from_edge] + edge.cost:
                dist[edge.to_edge] = dist[edge.from_edge] + edge.cost
                if i == N-1:
                    flag = True
    return dist, flag

if __name__ == "__main__":
    # https://atcoder.jp/contests/abc016/tasks/abc016_3
    N, M = l_inpl()

    edges = []

    for _ in range(M):
        u, v = l_inpl()
        u, v = u-1, v-1
        edges.append(Edge(u, v+N, 1))
        edges.append(Edge(u+N, v+N*2, 1))
        edges.append(Edge(u+N*2, v, 1))

    S, T = l_inpl()
    S, T = S-1, T-1

    ans = bellman_ford(S, edges, N*3)[0][T]

    if ans == INF:
        print((-1))
    else:
        print((ans//3))


# Optimized solution
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(eval(input()))
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

########

if __name__ == "__main__":
    N, M = l_inpl()

    to = [[] for _ in range(N)]

    for _ in range(M):
        u, v = l_inpl()
        u, v = u-1, v-1
        to[u].append(v)

    S, T = l_inpl()
    S, T = S-1, T-1

    dist = [[INF, INF, INF] for _ in range(N)]
    dist[S][0] = 0

    q = deque([])
    q.append([S, 0])

    while q:
        v, l = q.popleft()
        for v_to in to[v]:
            nl = (l + 1) % 3
            if dist[v_to][nl] != INF:
                continue
            dist[v_to][nl] = dist[v][l] + 1
            q.append([v_to, nl])
    
    ans = dist[T][0]
    if ans == INF:
        ans = -1
    else:
        ans = ans//3
    
    print(ans)