using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.ExceptionServices;
using System.Text;

namespace Contest
{

    class PriorityQueue<T>
    {
        private readonly List<T> heap;
        private readonly Comparison<T> compare;
        private int size;
        public PriorityQueue() : this(Comparer<T>.Default) { }
        public PriorityQueue(IComparer<T> comparer) : this(16, comparer.Compare) { }
        public PriorityQueue(Comparison<T> comparison) : this(16, comparison) { }
        public PriorityQueue(int capacity, Comparison<T> comparison)
        {
            this.heap = new List<T>(capacity);
            this.compare = comparison;
        }
        public void Enqueue(T item)
        {
            this.heap.Add(item);
            var i = size++;
            while (i > 0)
            {
                var p = (i - 1) >> 1;
                if (compare(this.heap[p], item) <= 0)
                    break;
                this.heap[i] = heap[p];
                i = p;
            }
            this.heap[i] = item;

        }
        public T Dequeue()
        {
            var ret = this.heap[0];
            var x = this.heap[--size];
            var i = 0;
            while ((i << 1) + 1 < size)
            {
                var a = (i << 1) + 1;
                var b = (i << 1) + 2;
                if (b < size && compare(heap[b], heap[a]) < 0) a = b;
                if (compare(heap[a], x) >= 0)
                    break;
                heap[i] = heap[a];
                i = a;
            }
            heap[i] = x;
            heap.RemoveAt(size);
            return ret;
        }
        public T Peek() { return heap[0]; }
        public int Count { get { return size; } }
        public bool Any() { return size > 0; }
    }

    struct S
    {
        public int I;
        public int Dist;
        public S(int i, int dist)
        {
            I = i;
            Dist = dist;
        }
    }

    class Program
    {
        private Scanner sc;
        private int N, M;
        private List<int>[] E;
        public void Solve()
        {
            sc = new Scanner();
            N = sc.NextInt();
            M = sc.NextInt();
            E = new List<int>[N];
            for (int i = 0; i < N; i++)
            {
                E[i] = new List<int>();
            }

            for (int i = 0; i < M; i++)
            {
                int u = sc.NextInt() - 1;
                int v = sc.NextInt() - 1;
                E[u].Add(v);
                //E[v].Add(u);
            }

            var dist = new int[N, 3];
            for (int i = 0; i < N; i++)
            {
                dist[i, 0] = -1;
                dist[i, 1] = -1;
                dist[i, 2] = -1;
            }

            int s = sc.NextInt() - 1;
            int t = sc.NextInt() - 1;
            var pq = new Queue<S>();
            pq.Enqueue(new S(s, 0));

            while (pq.Count > 0)
            {

                var pos = pq.Dequeue();
                if (dist[pos.I, pos.Dist % 3] != -1) continue;
                dist[pos.I, pos.Dist % 3] = pos.Dist;
                if (pos.I == t && pos.Dist % 3 == 0)
                {
                    Console.WriteLine(pos.Dist / 3);
                    return;
                }
                //Console.WriteLine($"{pos.I} {pos.Dist}");
                foreach (var i in E[pos.I])
                {
                    if (dist[i, (pos.Dist + 1) % 3] != -1) continue;
                    pq.Enqueue(new S(i, pos.Dist + 1));


                }
            }
            Console.WriteLine(-1);
        }

        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private readonly char _separator;
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

Measured memory_bytes: 27532