package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	finv, inv, fac [MAX]int
)

func COM(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func init() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

const (
	MOD = 1000000007
	MAX = 510000
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

type Po struct {
	i       int
	cnt     int
	counter int
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	t := strings.Split(sc.Text(), " ")
	N, _ := strconv.Atoi(t[0])
	M, _ := strconv.Atoi(t[1])

	P := [100010][]int{}
	for i := 0; i < M; i++ {
		sc.Scan()
		t := strings.Split(sc.Text(), " ")
		u, _ := strconv.Atoi(t[0])
		v, _ := strconv.Atoi(t[1])
		P[u] = append(P[u], v)
	}
	sc.Scan()
	t = strings.Split(sc.Text(), " ")
	S, _ := strconv.Atoi(t[0])
	T, _ := strconv.Atoi(t[1])
	queue := []*Po{{i: S, cnt: 0}}
	m := [100910][3]int{}
	for i := 1; i <= N; i++ {
		m[i][0] = -1
		m[i][1] = -1
		m[i][2] = -1
	}
	m[S][0] = 0
	for len(queue) > 0 {
		q := queue[0]
		queue = queue[1:]

		for _, d := range P[q.i] {
			counter := (q.cnt + 1) % 3
			if m[d][counter] != -1 {
				continue
			}

			m[d][counter] = m[q.i][q.cnt%3] + 1
			queue = append(queue, &Po{i: d, cnt: q.cnt + 1})
		}

	}
	if m[T][0] == -1 {
		fmt.Println(-1)
	} else {
		fmt.Println(m[T][0] / 3)
	}
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 25344