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*.
#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	
	int n,s,t;
	cin>>n>>s>>t;
	
	int a[n];
	for(int i = 0;i<n;i++){
	     cin>>a[i];
	}
	if(s==t){
	     cout<<0;
	}
	else{
	
	vector<int>v(n);
	vector<int>v2(n);
	int k = 1;
	for(int i = 0;i<n;i++){
	     v[i] = k;
	     v2[i] = k;
	     k++;
	}
/*	for(auto it : v){
	     cout<<it<<" ";
	}cout<<"\n";*/
	
	vector<int>v1(n,0);
   // int v1[n];
   
	
	int c = 0;
	int t1 = n;
	bool f = 1;
	while(t1--){
	       if(v1[t-1]==v2[s-1]){
	          
	          cout<<c;
	          f = 0;
	          break;
	     }
	     
	     int i = 0;
	     int k3 = -1;
	     vector<int>r(n,0);
	     while (i<n){
	          
	          v1[(a[i])-1] = v[i];
	    
	            
	            r[(a[i])-1] = v1[(a[i])-1];
	          i++;
	     }
	     v.clear();
	     
	     for(auto it : r){
	          v.push_back(it);
	     }
	     r.clear();
	     
	    /* for(auto it : v1){
	          cout<<it<<" ";
	     }cout<<"\n";*/
	     
	     c++;
	     
	     
	}
	if(f){
	     cout<<-1;
	}
	}
	
	
	
	return 0;
}

