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*.


ln0 = input()
ln1 = input()

n, s, t = map(int, ln0.split(' '))
P = list(map(lambda x: int(x) - 1, ln1.split(' ')))

if s == t:
    print(0)
    exit(0)

s -= 1
t -= 1
print(n, s, t, P)

static_ps = set()
p_map = {}
for i, p in enumerate(P):
    if p == i:
        static_ps.add(p)
    p_map[i] = p

if s in static_ps or t in static_ps:
    print(-1)
    exit(0)

processed = set()
groups = []

print(p_map)
curr_group = [next(iter(p_map.keys()))]

while p_map:
    k = curr_group[-1]
    if k in p_map:
        curr_group.append(p_map[k])
        del p_map[k]
    else:
        groups.append(curr_group)
        if p_map:
            curr_group = [next(iter(p_map.keys()))]

groups.append(curr_group)
print(groups)

for group in groups:
    group = group[1:]
    group_set = set(group)
    if s in group_set and t in group_set:
        si = group.index(s)
        ti = group.index(t)
        gn = len(group)
        res = (gn + ti - si) % gn
        print(res)
        exit(0)

print(-1)
exit(0)
