import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val m = cin.nextInt()

    val go = Array<MutableList<Int>>(n, { mutableListOf() })
    val d = Array<Array<Int>>(n, { Array<Int>(3, { -1 }) })

    for (i in 0..m-1) {
        val u = cin.nextInt() - 1
        val v = cin.nextInt() - 1
        go[u].add(v)
    }

    val s = cin.nextInt() - 1
    val t = cin.nextInt() - 1

    val queue: MutableList<Int> = mutableListOf(s)
    d[s][0] = 0

    var ans = -1

    while (queue.size != 0 && ans == -1) {
        val now = queue.removeAt(0)
        for (next in go[now]) {
            var will_add = false
            for (i in 0..2) {
                if (d[now][i] == -1) {
                    continue
                }
                val distance = d[now][i] + 1
                if (d[next][distance % 3] != -1) {
                    continue
                }
                if (next == t && distance % 3 == 0) {
                    ans = distance/3
                    break
                }
                d[next][distance % 3] = distance
                will_add = true
            }
            if (will_add) {
                queue.add(next)
            }
        }
    }
    println(ans)
}