#include <bits/stdc++.h>
using namespace std;
//#define ll long long
#define ll unsigned long long
#define ld long double
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);
#define NO cout << "NO" << endl
#define YES cout << "YES" << endl
#define vec vector<ll>
#define pi pair<ll, ll>
#define intarr(arr, n)       \
  ll arr[n];                 \
  for (ll i = 0; i < n; i++) \
  cin >> arr[i]
#define loop(i, a, b, c) for (ll i = a; i < b; i += c)
#define pb push_back
#define mkp make_pair
#define printarr(arr, n)     \
  for (ll i = 0; i < n; i++) \
  {                          \
    cout << arr[i] << " ";   \
  }                          \
  cout << endl
#define endl "\n"
#define MOD 1000000007
#define mem(dp, a) memset(dp, a, sizeof(dp));
#define all(v) v.begin(), v.end()
ll Ceil(ll a, ll b)
{
  if (a % b == 0)
    return a / b;
  else
    return a / b + 1;
}
ll gcd(ll a, ll b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
bool isSubSequence(string str1, string str2, int m, int n)
{
  if (m == 0)
    return true;
  if (n == 0)
    return false;
  if (str1[m - 1] == str2[n - 1])
    return isSubSequence(str1, str2, m - 1, n - 1);
  return isSubSequence(str1, str2, m, n - 1);
}

bool SieveOfEratosthenes(ll n)
{
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));

  for (ll p = 2; p * p <= n; p++)
  {
    if (prime[p] == true)
    {
      for (ll i = p * p; i <= n; i += p)
        prime[i] = false;
    }
  }
  return prime[n];
  // for (int p=2; p<=n; p++)
  //    if (prime[p])
  //       cout << p << " ";
}

// unordered_map<ll,vec> m,final;
// map<ll,ll> height,subtree;
// unordered_map<ll,bool> visited;

// void noOfNodesInEachSubtree(ll s,ll e){
//   subtree[s]=final[s].size();
//   for(ll i=0;i<final[s].size();i++){
//     if(final[s][i]==e) continue;
//     subtreefunc(final[s][i],s);
//     subtree[s]+=subtree[final[s][i]];
//   }
//   return;
// }

// void dfs(){
//   height[1]=0;
//   queue<ll> q;
//   q.push(1);
//   visited[1]=true;
//   while(!q.empty()){
//     ll f=q.front();
//     for(ll i=0;i<m[f].size();i++){
//       if(!visited[m[f][i]]){
//         final[f].pb(m[f][i]);
//         height[m[f][i]]=height[f]+1;
//         visited[m[f][i]]=true;
//         q.push(m[f][i]);
//       }
//     }
//     q.pop();
//   }
//   subtreefunc(1,0);
//   for(auto i:subtree)
//       i.second--;

// }

bool isPrime(ll n)
{
  // Corner cases
  if (n <= 1)
    return false;
  if (n <= 3)
    return true;

  // This is checked so that we can skip
  // middle five numbers in below loop
  if (n % 2 == 0 || n % 3 == 0)
    return false;

  for (ll i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0)
      return false;

  return true;
}

bool cmp(pair<ll, ll> a, pair<ll, ll> b)
{
  return a.second < b.second;
}
void solve()
{
  ll n,m;
  cin>>n>>m;
  ll a[n+1];
  for(ll i=1;i<=n;i++){
    cin>>a[i];
  }
  unordered_map<ll,ll> mp;
  vec v;
  ll curr=1;
  ll c=1;
  ll start;
  while(m>0){
    if(mp[a[curr]]) {
      start=mp[a[curr]];
      break;
    }
    v.pb(a[curr]);
    mp[a[curr]]=c++;
    curr=a[curr];
    m--;
  }
  if(m==0){
    cout<<curr;
    return;
  }
  vec v2;
  cout<<endl;
 // cout<<start<<" ";
  v2.pb(v[v.size()-1]);
  for(ll i=start-1;i<v.size()-1;i++){
    v2.pb(v[i]);
  }
  //for(ll i=0;i<v.size();i++)cout<<v2[i];
  ll total=v2.size();
  ll ans=m%total;
  cout<<v2[ans];

}

int main()
{
  fastio;
  ll t;
  t = 1;
  //cin >> t;
  //ll sum = 0;
  //func();

  //cout<<gcd(4,9)<<endl

  while (t--)
  {
    //ll next = solve();
    //cout<<next<<endl;
    //sum += next;
    solve();
    //solve2();
  }
  //cout << sum;
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

  return 0;
}


Measured memory_bytes: 15092