function D167(_input) {
    var lines = _input.split("\n");
    var first = lines.shift().split(' ').map(v => v*1);
    var Cnum = first[0]; // 町の数
    var pNum = BigInt(first[1]); // 移動する数
    var r = lines.shift().split(' ').map(v => v*1); // ルート

    var current = 1;
    var route = '1';
    var start = 0;
    var end = 0;

    for (var i = 0; i < Cnum; i++) {
        current = r[current - 1];
        if (route.indexOf(current + "") !== -1) {
            start = route.indexOf(current + "");
            end = i + 1;
            break;
        }
        route += current;
    }

    var syuki = end - start;

    if (start > pNum) {
        console.log(route[pNum]);
        return;
    }

    var s = BigInt(start);
    var num = s + ((pNum - s) % BigInt(syuki));

    console.log(route[num]);
}
D167(require("fs").readFileSync("/dev/stdin", "utf8"));
