#include<stdio.h>
int main(){
	int n,s,ans1=1,ans;
  	long int k;
    scanf("%d %ld",&n,&k);
  	int a[n];
	for(int i=1;i<=n;i++){
      scanf("%d",&a[i]);
    }
  for(long int m=1;m<=n%k+1;m++){
  	ans=a[ans1];
    ans1=ans;
  }
  printf("%d",ans1);
}