#include <stdio.h>

int main(void) {
    
    long long N, K;
    scanf("%lld", &N); scanf("%lld", &K);

    int towns[N];
    for (int i=0; i<N; i++) {
        scanf("%d", &towns[i]);
    }

    int repeated[3];

    int location = 1;
    location = towns[0];
    for (int i=0; i<K-1; i++) {
        location = towns[location-1];
        if (i < 3) {
            repeated[i] = location;
        } else {
            break;
        }
    }

    int index = (K%N)-1;
    if (index > 3) {index -= 4;}
    printf("%d\n", repeated[index]);

}