

N,M=gets.chomp.split.map(&:to_i)

redges=Array.new(N){Array.new}
M.times do
  u,v=gets.chomp.split.map(&:to_i)
  redges[v-1] << u-1
end

s,t=gets.chomp.split.map(&:to_i)
S,T=s-1,t-1
canGo=Array.new(N){Array.new(3,-1)}
stack=[[T,0]]


while stack.size!=0
  to,count=stack.pop
  if canGo[to][count%3]!=-1
    next
  end
  canGo[to][count%3]=count
  redges[to].each do |toto|
    stack << [toto,count+1]
  end
end

puts canGo[S][0]!=-1 ? canGo[S][0]/3 : -1
