n, m = gets.to_s.split.map{|t|t.to_i}

edges = Array.new(n){ []}
m.times do
  u, v = gets.to_s.split.map{|t|t.to_i-1}
  edges[u] << v
end

s, t = gets.to_s.split.map{|i|i.to_i-1}

inf = 10 ** 9
dist = Array.new(n){ Array.new(3){ inf } }
dist[s][0] = 0

q = [[s,0]]
while q.any?
  
  u, x = q.shift
  y = (x+1) % 3
  edges[u].each do |v|
    next if dist[v][y] != inf# || dist[u][x] == inf
    dist[v][y] = dist[u][x] + 1
    if v == t && y == 0
      puts dist[v][y] / 3
      exit
    end
    q.push([v, y])
  end
end

puts dist[t][0] == inf ? -1 : dist[t][0] / 3