# class UnionFind

#   attr_accessor :nodes, :sizes

#   def initialize(num)
#     self.nodes = []
#     self.sizes = []

#     num.times do |n|
#       self.nodes[n] = n
#       self.sizes[n] = 1
#     end
#   end

#   def root(i)
#     # Loop up the chain until reaching root
#     while nodes[i] != i do
#       # path compression for future lookups
#       nodes[i] = nodes[nodes[i]]
#       i = nodes[i]
#     end
#     i
#   end

#   def union(i, j)
#     rooti = root i
#     rootj = root j

#     # already connected
#     return if rooti == rootj

#     # root smaller to root of larger
#     if sizes[i] < sizes[j]
#       nodes[rooti] = rootj
#       sizes[rootj] += sizes[rooti]
#     else
#       nodes[rootj] = rooti
#       sizes[rooti] += sizes[rootj]
#     end
#   end

#   def connected?(i, j)
#     root(i) == root(j)
#   end

# end

N, M = gets.split.map &:to_i

# uf = UnionFind.new(N)

pathes = N.times.map{ [] }
M.times{
  from, to = gets.split.map(&:to_i).map &:pred
  pathes[from] << to
}
S, T = gets.split.map(&:to_i).map &:pred

# p pathes

kpathes = N.times.map{ [] }
N.times{|from|
  q = {}
  q[from] = 1
  cnt = 0
  while !q.empty?
    cnt += 1
    new_q = {}
    q.each_key{|from|
      pathes[from].each{|to|
        new_q[to] = 1
      }
    }
    if cnt == 3
      new_q.each_key{|to|
        kpathes[from] << to
      }
      break
    end
    q = new_q
  end
}
kpathes.map! &:uniq
# p kpathes

# N.times{|from|
#   kpathes[from].each{|to|
#     uf.union(from, to)
#   }
# }
# if !uf.connected?(S, T)
#   p -1
#   exit
# end

ans = 0
q = {}
q[S] = 1
used = [false] * N
used[S] = true
while !q.empty?
  ans += 1
  new_q = {}
  q.each_key{|from|
    kpathes[from].each{|to|
      next if used[to]
      if to == T
        p ans
        exit
      end
      new_q[to] = 1
    }
  }
  q = new_q
end
p -1