/*“proffeser,berlin,rio,arjun,kabirsingh,carry”*/

#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
//#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 10000005
#define se second
#define fi first
#define edge pair<ll,ll>
#define mod 998244353
using namespace std;
 
 //ttl=1<<n;   2^n
 //n>>=1;      n/2
 
// ¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++¦¦¦++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦¦¦¦¦¦¦¦¦+++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦+++++++¦++¦¦
// ¦¦¦¦¦¦¦¦++¦¦¦¦¦¦++++++¦¦¦¦+++++++++++++¦
// ¦¦¦¦¦¦¦++++++¦¦¦++++++¦¦++++++++++++++¦¦
// ¦¦¦¦¦¦¦+++++++¦¦¦+++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++¦¦¦¦¦¦¦¦+++++++¦ 
// ¦¦¦¦¦¦¦¦¦¦++¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦++++¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦ 
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦+¦++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++¦¦+++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦¦+++¦¦¦¦++++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++¦¦+¦¦¦¦¦+++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦+++++++++++¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦¦¦¦

//ll dp[maxx];
//ll par[maxx];

//vector<ll>v;
//sqrt(n)
/*
bool isprime(ll n)
{
    if(n==1)
    return false;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        return false;
    }
    return true;
}*/

////////////////////////////////////////////sieve/////////////////////////////////////////////////////
/*
void sieve()
{
    ll n=1000000;
        ll i;
    ll prime[n+1]={0};    
    ll j;
    prime[1]=1;
    prime[0]=1;
    for(i=2;i*i<=n;i++)
    {
        if(prime[i]==0)
        {
            for(j=2*i;j<=n;j=j+i)
            {
                prime[j]=1;
            }
        }
    }
    ll cnt=0;
    for(i=0;i<=n;i++)
    {
        if(prime[i]==0)
        cnt++;
        
        if(prime[cnt]==0)
        pp[i]=1;
        else
        pp[i]=0;
    }
    for(i=1;i<=n;i++)
    {
        pp[i]+=pp[i-1];
    }

}*/    




//map<ll,ll>f;
//map<pair<ll,ll>,ll>m;


////////////////////////////////////////////////matrix power///////////////////////////////////////////////////
/*ll ar[2][2];
ll I[2][2];


void mul(ll A[][2],ll B[][2],ll m)
{
    ll res[m+1][m+1];
    rep(i,m)
    {
        rep(j,m)
        {
            res[i][j]=0;
            rep(k,m)
            {
                res[i][j]=res[i][j]%mod;
                res[i][j]+=(A[i][k]*B[k][j])%mod;
                res[i][j]=res[i][j]%mod;
            }
            
        }
    }
    rep(i,m)
    {
        rep(j,m)
        {
            A[i][j]=res[i][j];
        }
    }
}

void power(ll a[][2],ll m,ll n)
{
    rep(i,m)rep(j,m)
    {
        if(i==j)
        I[i][j]=1;
        else
        I[i][j]=0;
    }
    
    while(n)
    {
        if(n%2)
        {
            //I=I*a;
            mul(I,a,2);
            n--;    
        }
        else
        {
            //a=a*a;
            mul(a,a,2);
            n/=2;
        }    
    }
    
    rep(i,m)
    {
        rep(j,m)
        {
            a[i][j]=I[i][j];
        }
    }
}
/*
void print(ll a[][maxx],ll m)
{
    rep(i,m)
    {
        rep(j,m)
        {
            cout<<(a[i][j])%mod<<" ";
        }
        cout<<endl;
    }
}
*/









//////////////////////////mod_pow////////////////////////////
/*
ll mod_pow(ll a,ll n)
{
	ll res=1;
	while(n)
	{
		if(n&1)
		{
			n--;
			res=((res)%mod)*((a)%mod);
			res=res%mod;
		}
		else
		{
			n/=2;
			a=((a%mod)*(a%mod))%mod;
		}
	}
	return res;
}*/
///////////////////////////////////////////////////////////////






//do it 
// don't ask
// don't stop don't stop doing don't stop doing don't stop doing
// DON'T GIVE UP


// a^b = a+b-2*(a&b)









//////////////////////////////////////////////////////LIS (NLOGN)///////////////////////////////////////////////////////
/*
ll CeilIndex(std::vector<ll>& v, ll l, ll r, ll key) 
{ 
    while (r - l > 1) { 
        ll m = l + (r - l) / 2; 
        if (v[m] >= key) 
            r = m; 
        else
            l = m; 
    } 
  
    return r; 
} 
  
ll LongestIncreasingSubsequenceLength(std::vector<ll>& v) 
{ 
    if (v.size() == 0) 
        return 0; 
  
    std::vector<ll> tail(v.size(), 0); 
    ll length = 1; // always points empty slot in tail 
  
    tail[0] = v[0]; 
    for (size_t i = 1; i < v.size(); i++) { 
  
        // new smallest value 
        if (v[i] < tail[0]) 
            tail[0] = v[i]; 
  
        // v[i] extends largest subsequence 
        else if (v[i] > tail[length - 1]) 
            tail[length++] = v[i]; 
  
        // v[i] will become end candidate of an existing 
        // subsequence or Throw away larger elements in all 
        // LIS, to make room for upcoming grater elements 
        // than v[i] (and also, v[i] would have already 
        // appeared in one of LIS, identify the location 
        // and replace it) 
        else
            tail[CeilIndex(tail, -1, length - 1, v[i])] = v[i]; 
    } 
  
    return length; 
} 


*/
////////////////////////////////////////////////////////////////////////////////////////




//////////////////////////count set bits////////////////////////////////
/*
ll cb(ll n) 
{ 
    ll count = 0; 
    while (n) { 
        count += n & 1; 
        n >>= 1; 
    } 
    return count; 
} 
  */

int main()
{
	
	ll n,k;
	cin>>n>>k;
	ll i=0;
	ll a[n+1];

	ll x=0;
	x=k%n;
	
	
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		
	}
	
    map<ll,ll> mp;

    i = 1;
    ll t = i;
    mp[i]=1;

    ll cnt = 0;

    while(1){

        t = a[t];
        cnt++;
        if(mp[t]){
            break;
        }
        mp[t] = 1;

    }

    ll tmp = 0;
    ll cnt1 = 0;
    ll t1 = t;

    while(1){
        if(tmp==1){
            break;
        }
        t1 = a[t1];
        cnt1++;
        if(t1==t){
            tmp=1;
        }
    }

    if(k<=cnt){

        ll ans = 1;
        for(i=0;i<k;i++){
            ans = a[ans];
        }
        cout << ans << endl;

    }
    else{

        k = k-cnt;
        ll ans = t;
        k = k%cnt1;
        for(i=0;i<k;i++){
            ans = a[ans];
        }
        cout << ans << endl;

    }

	return 0;	
} 
//cout<<"YES"<<endl;

//cout<<"NO"<<endl;

Measured memory_bytes: 17484