n,m = gets.split.map(&:to_i)

a = Array.new(n){[]}
m.times do
	u,v = gets.split.map(&:to_i)
	a[u-1] << v-1
end

s,t = gets.split.map{|x| x.to_i - 1}
b = Array.new(n){ Array.new(3, -3) }
b[s][0] = 0 
p = [[s,1]]

until (p.empty? || (b[t][0]!=-3))
	from,cnt = p.shift
	a[from].each do |to|
		if b[to][cnt] == -3
			b[to][cnt] = b[from][(cnt - 1)%3] + 1
			p << [to,(cnt+1) %3]
		end
	end
end

puts b[t][0]/3