#include<stdio.h>
 
#define N 200000

int n, a[N], orderPass[N];
long k;

int main(){
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++){
        scanf("%d",&a[i]);
        orderPass[i] = -1;
    }

    int  currPos, nextPos, nRoop=-1, nNonRoop;
    currPos = 1;
    orderPass[currPos-1] = 0;
    for (int i = 1; i < n; i++){
        nextPos = a[currPos-1]; 
        if(orderPass[nextPos-1]>=0){
            nNonRoop = orderPass[nextPos-1]; 
            nRoop = i-nNonRoop;
            break;
        }
        orderPass[nextPos-1] = i;
        currPos = nextPos;
//        for (int i = 0; i < n; i++){
//            printf("%d ",orderPass[i]);
//        } printf("\n");
    }

//    for (int i = 0; i < n; i++){
//        printf("%d ",orderPass[i]);
//    } printf("\n");

    if(nRoop==-1){
        printf("%d\n", nextPos);
    }
    else{
        for (int i = 0; i < n; i++){
            if ( nNonRoop + (k-nNonRoop)%nRoop == orderPass[i]){
                printf("%d\n", i+1);
            }
        }
    }
    return 0;
}
