#include <stdio.h>
int main()
{
  int i,j=0,a[100000],n,s,b[10000];
  long long m;
  scanf("%d %lld",&n,&m);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  s=a[n-1];
  do
  {
    b[j]=s;
    s=a[s-1];
    j++;
  }while(s!=a[0]);
  printf("%d\n",b[m%j-1]);
  return 0;
}