#include<stdio.h>
int main()
{
    long long int a[210000],k,i,n,j,next,count=1,temp[210000],countc=1,last,ccn;
	
	scanf("%lld%lld", &n,&k);
	for(i=1; i<=n;i++){
		scanf("%lld", &a[i]);
temp[i]=0;
	}
  i=1;
  temp[1]++;
  while(1){
    next=a[i];
    count++;
    temp[next]++;
    if(temp[next]==2){
      break;
    }
    i=next;
  }
  last=next;
  i=1;
    while(1){
    next=a[i];
    countc++;
    if(next==last){
      break;
    }
    i=next;
  }
  
  ccn=count;

  i=1;
  
      while(1){
    next=a[i];
    if(a[i]==last){

      break;
    }
      count++;
  if(count==k){
          printf("%lld",a[i-1]);
        }
    i=next;

  }
    j=(k-count)%(ccn-countc);
  
  count=0;
  i=next;
    while(1){
    next=a[i];
    if(count+1==j){
      printf("%lld\n",a[i]);
      return 0;
    }
      count++;
    i=next;
  }
}
