#include <stdio.h>

int	main(void)
{
  	int 	n;
  	long long 	k;
  	int 	a[200002][2];
  	int  	i;
  	int 	c;
  	int     d;
  	int     e;
  	int     f;
  	int     g;
  
  	scanf("%d %lld\n", &n, &k);
  	for(i=1; i<=n; i++)
    {
      	scanf("%d", &a[i][0]);
      	a[i][1] = 0;
    }
    
  	a[0][0] = 0;
  	a[0][1] = 0;
  	
  	c = 0;
  	d = 0;
  	e = 0;
  	f = 0;
  	g = 0;
  	for(i=1; i<=n; i++)
    {
      	if (a[ a[i][0] ][1] == 1)
      	{
      	    c++;
      	    if ( e == 0 )
          	{
          	    d = c - 1;
          	    e = 1;
          	}
          	a[ a[i][0] ][1] += 1;
      	}
      	else if(a[ a[i][0] ][1] == 2)
      	{
      	    c++;
      	    if ( g == 0 )
      	    {
      	        f = c - 1;
      	    }
      	    break ;
      	}
     	else
     	{
          	c++;
          	a[ a[i][0] ][1] += 1;
     	}
    }
  	
  	if (f == d)
  	{
  	    printf("%d", a[(k - d) % c + 2][0]);
  	}
  	else
  	{
  	    printf("%d", a[(k - d) % (f - d)][0]);
  	}
  	return (0);
}