Petya and Vasya are playing a game. Petya's got *n* non-transparent glasses, standing in a row. The glasses' positions are indexed with integers from 1 to *n* from left to right. Note that the positions are indexed but the glasses are not.

First Petya puts a marble under the glass in position *s*. Then he performs some (possibly zero) shuffling operations. One shuffling operation means moving the glass from the first position to position *p*<sub class="lower-index">1</sub>, the glass from the second position to position *p*<sub class="lower-index">2</sub> and so on. That is, a glass goes from position *i* to position *p*<sub class="lower-index">*i*</sub>. Consider all glasses are moving simultaneously during one shuffling operation. When the glasses are shuffled, the marble doesn't travel from one glass to another: it moves together with the glass it was initially been put in.

After all shuffling operations Petya shows Vasya that the ball has moved to position *t*. Vasya's task is to say what minimum number of shuffling operations Petya has performed or determine that Petya has made a mistake and the marble could not have got from position *s* to position *t*.
The first line contains three integers: *n*, *s*, *t* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>; 1 ≤ *s*, *t* ≤ *n*) — the number of glasses, the ball's initial and final position. The second line contains *n* space-separated integers: *p*<sub class="lower-index">1</sub>, *p*<sub class="lower-index">2</sub>, ..., *p*<sub class="lower-index">*n*</sub> (1 ≤ *p*<sub class="lower-index">*i*</sub> ≤ *n*) — the shuffling operation parameters. It is guaranteed that all *p*<sub class="lower-index">*i*</sub>'s are distinct.

Note that *s* can equal *t*.
from sys import stdin
import sys
import math
class PriorityQueueBase:
    class _Item:
        __slots__ = '_key','_value'

        def __init__(self,k,v):
            self._key = k
            self._value = v

        def __lt__(self,other):
            return self._key < other._key

    def is_empty(self):
        return len(self) == 0

def queue_time(customers,n):
    for i in range(1,len(customers)):
        i = i%n
        while i%n<n and customers[i%n]>customers[(i+1)%n]:
            i+=1
            customers[i%n] =customers[i%n] + customers[i]
            customers[i] = 0
    return customers

def phi(n):
    result = n
    for i in range(2,int(pow(n,0.5))+1):
        while n%i == 0:
            n/=i
            result-=result/i
    if n>1:
        result -= result/n
    return result

class heap:
    def __init__(self,data):
        self.data = data
    def parent(self,j):
        return (j-1)//2
    def left(self,j):
        return 2*j+1
    def right(self,j):
        return 2*j+2
    def hasr(self,j):
        return self.right(j)<len(self.data)
    def hasl(self,j):
        return self.left(j)<len(self.data)
    def swap(self,i,j):
        self.data[i],self.data[j] = self.data[j],self.data[i]
    def upheap(self,j):
        parent = self.parent(j)
        if j>0 and self.data[j]<self.data[parent]:
            self.swap(j,parent)
            self.upheap(parent)
    def downheap(self,j):
        if self.hasl(j):
            left = self.left(j)
            small = left
            if self.hasr(j):
                right = self.right(j)
                if self.data[left]>self.data[right]:
                    small = right
            if self.data[small]<self.data[j]:
                self.swap(j,small)
                self.downheap(small)
    def __str__(self):
        return ' '.join(map(str,self.data))

'''
p = [100,5,4,33,2,1,99,0]
a = heap(p)
start = a.parent(1)
for i in range(start,len(p)):
    a.upheap(i)
print(a)
'''

n,s,t = map(int,input().split())
a = list(map(int,input().split()))
move = 0
temp = None
while s!=t:
    move+=1
    s = a[s-1]
    if temp:
        if temp == s:
            print(-1)
            sys.exit()
            break
    temp = s
print(move)
































































