#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, s, e, count = 0, kk = 0;
  cin >> n >> s >> e;
  int a[n];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int ball = s;
  while (ball != e) {
    ball += a[ball] - ball;
    count++;
    kk++;
    if (ball == s) {
      cout << "-1";
      return 0;
    }
  }
  cout << count;
}
