import java.util.*
import java.util.zip.Inflater

const val INF = 1000000000

class Node(val num: Int) {
    val adj = mutableListOf<Node>()
    var dMod = mutableListOf(INF, INF, INF)

    fun adjAdd(v: Node) {
        adj.add(v)
    }
}

fun main(args: Array<String>){
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    val graph = mutableListOf(Node(0))
    for (i in 1 until n + 1) graph.add(Node(i))
    for (j in 0 until m) {
        val (u, v) = readLine()!!.split(" ").map(String::toInt)
        graph[u].adjAdd(graph[v])
    }

    val (s, t) = readLine()!!.split(" ").map(String::toInt)
    graph[s].dMod[0] = 0
    var depth = 1
    var queue = ArrayDeque(listOf(graph[s]))
    do {
        val nextQueue = ArrayDeque<Node>()
        while (queue.size > 0) {
            val v = queue.poll()
            v.adj.forEach {
                if (it.num == t && depth % 3 == 0) {
                    println(depth / 3)
                    return
                }
                if (it.dMod[depth % 3] > depth) {
                    it.dMod[depth % 3] = depth
                    nextQueue.add(it)
                }
            }
        }
        queue = nextQueue
        depth++
    } while (queue.size > 0)
    println(-1)
}
