using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Linq.Expressions;
using System.Xml.XPath;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, M) = Slice2<long>();
            var graph = new long[N].Select(_ => new List<long>()).ToArray();
            for (var i = 0; i < M; ++i)
            {
                var (u, v) = Slice2<long>();
                graph[--u].Add(--v);
            }
            var (S, T) = Slice2<long>();
            var MAX = long.MaxValue;
            var dp = new long[N].Select(_ => new int[3].Select(__ => MAX).ToArray()).ToArray();
            dp[S - 1][0] = 0;
            var q = new Queue<(long node, long dst, long p)>();
            q.Enqueue((S - 1, 0, 0));
            while (q.Any())
            {
                var v = q.Dequeue();
                var u = v.node;
                var p = v.p;
                var np = (p + 1) % 3;
                foreach (var to in graph[u])
                {
                    if (dp[to][np] != MAX) continue;
                    dp[to][np] = dp[u][p] + 1;
                    q.Enqueue((to, dp[to][np], np));
                }
            }
            if (MAX == dp[T - 1][0])
                WriteLine(-1);
            else
                WriteLine(dp[T - 1][0] / 3);
        }

        static long Gcd(long x, long y) => y == 0 ? x : Gcd(y, x % y);
        static long Lcm(long x, long y) => x / Gcd(x, y) * y;

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 57260