#include<bits/stdc++.h>
#define int long long int 
#define hell 1000000007 
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(int int i = a;i<b;i++)
#define pi 3.1415926536
#define Mod 998244353
#define endl '\n'
  //char a[2000][2000];
  using namespace std;
  int sum (int a)
  {
      int sum =0;
      while(a>0)
      {
          sum = sum + (a%10);
          a=a/10;
      }
      return sum;
  }
  int count_digit(int n)
  {
     int  count =0;
      while(n>0)
      {
          n = n/10;
          count++;
          //count++;
      }
      return count;
  }
  int binarySearch(int x,int y ,int z ,vector<int> v)
  {
      int low = x;
      int high = y;
      int mid = x+(y-x)/2;
      while(low<=high)
      {
          if(v[mid]==z)
              return mid;
          if(v[mid]<z)
              return binarySearch(mid+1,high,z,v);
          if(v[mid]>z)
              return binarySearch(low,mid-1,z,v);
      }
      return -1;
  }
int modularExponentiation(int x, int y, int m) 
{ 
    if (y == 0) 
        return 1; 
    int p = modularExponentiation(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 
  int binaryExponentiation(int x,int n)
  {
      if(n==0)
          return 1;
      else if(n%2 == 0)        //n is even
          return binaryExponentiation(x*x,n/2);
      else                             //n is odd
          return x*binaryExponentiation(x*x,(n-1)/2);
  }
 
 
 
 
  set<int> s;
  //vector<int> v;
  void genrate(int n,int len,int max)
  {
      if(len>max)
          return ;
      s.insert(n);
      genrate(n*10+1,len+1,max);
      genrate(n*10+0,len+1,max);
  }
  // bool visited[200005];
  // vector<int> v[200005];
  // bool recur[200005];
  // int c = 0;
  // void dfs(int x ,int parent)
  // {
  //    visited[x] = 1;
  //    if(v[x].size() != 2)
  //     c = -1;
  //    for(int i = 0;i<v[x].size();i++){
  //     if(v[x][i] == parent)
  //       continue;
  //     if(visited[v[x][i]] && v[x].size() == 2 && c ==  0)
  //         c = 1;
  //     else if(!visited[v[x][i]]){
  //      dfs(v[x][i],x);
  //    }
  //    //return false;
  //     }
  // }
  //memset(level,0,sizeof(level));    
  /*void topological_sort(int x)
  {
      visited[x] = 1;
    //  sort(aint(v[x]));
      for(int i =0;i<v[x].size();i++)
      {
          if(visited[v[x][i]]!=1){
              //level[v[x][i]] = level[x]+1;
              topological_sort(v[x][i]);
          }
      }
      ans.pb(x);
  }*/
  //char a2001][2001];
  ///**************** Cycle using DSU *********************///
 
 
int my_lower(vector<int> &v, int X){
  int lo = 0, hi = v.size()-1;
  if(v.size() ==  0)
    return -1;
  while(hi-lo > 1){
    int mi = (lo+hi)/2;
    if(v[mi] < X){
      lo = mi;
    }
    else
      hi = mi-1;
  }
  int ans = -1;
  for(int i = lo;i<=hi;i++){
    if(v[i] < X){
      ans = i;
    }
  }
  if(ans != -1 && v[ans] < X){
    return ans;
  }
  else
    return -1;
}
int my_upper(vector<int> & v, int X){
  if(v.size() == 0)
    return -1;
   int lo = 0, hi = v.size()-1;
  while(hi-lo > 1){
    int mi = (lo+hi)/2;
    if(v[mi] < X){
      lo = mi+1;
    }
    else
      hi = mi;
  }
  int ans = -1;
  for(int i = hi;i>=lo;i--){
    if(v[i] > X){
      ans = i;
    }
  }
  if(ans != -1 && v[ans] > X){
    return ans;
  }
  else
    return -1;
}
/* Helper Function */

bool comp(pair<int,int> p1, pair<int,int> p2){
  if(p1.F > p2.F)
    return 1;
  if(p1.F == p2.F){
    if(p1.S < p2.S)
      return 1;
    else
      return 0;
  }
  else
    return 0;
}
int mod(int a, int b)
{
    int r = a % b;
    return r < 0 ? r + b : r;
}
int32_t main()
  {   
      ios_base::sync_with_stdio(false);
      cin.tie(0);
      cout.tie(0);            
      //std::setprecision(20);      
      int tests=1;
      //freopen("input.txt", "r", stdin);
       // cin>>tests;
    while(tests--)
    { 
       int n,k;
       cin>>n>>k;
       vector<int> v[200005];
       for(int i = 1; i<=n ;i++){
         int x;
         cin>>x;
         v[i].pb(x);
       }
       vector<int> ans;
       bool vis[200005];
       memset(vis, 0, sizeof(vis));
       queue<int> q;
       q.push(1);
       while(!q.empty()){
        int x = q.front();
        q.pop();
        if(vis[x]){
          ans.pb(x);
          break;
        }
        vis[x] = 1;
        ans.pb(x);
        for(int i = 0;i<v[x].size();i++)
          q.push(v[x][i]);
       }
       int cnt[n+1];
       memset(cnt, 0, sizeof(cnt));
       int cycle = 0;
       for(int i = 0;i<ans.size();i++){
         cnt[ans[i]]++;
          if(cnt[ans[i]] == 2){
            cycle = ans[i];
            break;
        }}
        if(cycle){
          ans.pop_back();
          int i  = 0;
          while(ans[i] != cycle && k){
            i++;
            k--;
          }
          if(k == 0){
            cout<<ans[i];
          }
          else{
            k = k%(ans.size()-i);
            cout<<ans[i+k];
          }
        }
        else{
          if(k >= ans.size()){
            cout<<ans[ans.size()-1];
          }
          else
            cout<<ans[k];
        }
       
    }
} 

Measured memory_bytes: 17396