#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef long long ll;
int main(void)
{
  ll n,k;
  scanf("%lld%lld",&n,&k);
  ll a[n+1],b[n],tmp=1,ans=0;
  for(ll i=1;i<=n;i++){
    scanf("%lld",&a[i]);
    b[i]=0;
  }
  b[1]=1;
  ll flag=2;
  ll sum=0,j=0,cnt1=k,cnt2=0,cnt;
  while(j<=k){
    sum=a[tmp];
    b[sum]++;
    tmp=a[sum];
    j++;
    if((b[sum]==2)&&(flag==2)){
      flag--;
      cnt1=j;
    }else if((b[sum]==3)&&(flag==1)){
      cnt2=j-cnt1;
      break;
    }
  }
  cnt=cnt1-cnt2;
  tmp=1;
  ll c[cnt1+1];
  c[0]=1;
  for(int i=1;i<=(cnt1);i++){
    c[i]=a[tmp];
    tmp=a[tmp];
  }
  
  if(cnt>=0){
  if(k<=cnt1) printf("%lld ",c[k]);
  else if(k>cnt1){
    if(((k-cnt)%cnt2)!=0) printf("%lld ",c[(k-cnt)%cnt2+cnt]);
    else printf("%lld ",c[cnt2+cnt]);
  }
  }else{
    printf("%lld ",c[(k-cnt1)%cnt2+cnt1]);
  }
  //printf("%lld ",cnt);
  
         
  //for(int i=1;i<=(cnt1);i++) printf("%lld ",c[i]);

  return 0;
}