#include <stdio.h>

int main() {
	long long n, k, a[10000000], record[10000000]/*町の履歴*/, number[100000000]	/*各町の登場回数*/, ffrecord[10000000]/*ループ部の中身*/, town = 0, start = 0/*ループ開始点*/, goal = 0/*終点*/, y = 0/*ループの長さ*/, z = 0/*ループで数列を割ったときのあまり*/;
	scanf("%lld%lld", &n, &k);
	for (int i = 0; i < n; i++)scanf("%lld", &a[i]);
	town = a[0];
	record[0] = 1;
	number[0] += 1;
	record[1] = a[0];
	number[a[0] - 1] += 1;
	//1町目の無限ループの場合
	if (number[a[0] - 1] == 2) {
		printf("1");
		goto Finish;
	}
	//町が二度出た場合の重複探し
	for (long long j = 0; j <10000000; j++) {
		town = a[town - 1];
		record[j + 2] = town;
		number[town - 1] += 1;
		if (number[town - 1] == 2) {
			goal = j + 2;
			break;
		}
	}
	//2回出た文字の初登場
	for (long long l = 0; l < goal; l++) {
		if (record[l] == town) {
			start = l;
			break;
		}
	}
	//文字列の長さの検出と規則性の部分のぬきだし
	for (long long m = 0; m < goal - start; m++) {
		ffrecord[m] = record[m + start];
		y++;
	}
	//出力の場合分け
	if (k < goal - start)printf("%lld", record[k]);
	else if (number[0] == 2) {
		z = (k - (goal - start) + 1) % (goal - start);
		if (z == 0)printf("%lld", ffrecord[y - z - 1]);
		else printf("%lld", ffrecord[z - 1]);
	}
	else {
		z = (k - start + 1) % (goal - start);
		if (z == 0)printf("%lld", ffrecord[y - z - 1]);
		else printf("%lld", ffrecord[z - 1]);
	}
Finish:;
}