import scala.io.StdIn._
import scala.collection.mutable.{ArrayBuffer, HashSet}
object Main extends App {
  val Array(n, m) = readLine.split(" ").map(_.toInt)
  val vs = Array.fill(n + 1)(new ArrayBuffer[Int]())
  (1 to m).foreach { i =>
    val Array(u, v) = readLine.split(" ").map(_.toInt)
    vs(u) += v
  }
  val Array(s, t) = readLine.split(" ").map(_.toInt)

  val arrived = new HashSet[Int]()

  def loop(cnt: Int, curs: Seq[Int]): Int = {
    val nexts = for {
      start <- curs
      hop <- vs(start)
      step <- vs(hop)
      jump <- vs(step)
      if !arrived.contains(jump)
    } yield {
      arrived += jump
      jump
    }

    if (nexts.contains(t)) cnt
    else if (nexts.isEmpty) -1
    else loop(cnt + 1, nexts)
  }

  println(loop(1, Seq(s)))
}