macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// x ** n % mods を求める
fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

// nCk の組み合わせを列挙する
fn combination(n: usize, k: usize) -> Vec<Vec<usize>> {
    let mut ans = Vec::new();
    if k == 1 {
        for i in 1..n+1 {
            let mut tmp = Vec::new();
            tmp.push(i);
            ans.push(tmp);
        }
    }
    else {
        for iter in combination(n-1, k-1) {
            let max = iter.iter().max().unwrap();
            for j in *max+1..n+1 {
                let mut tmp = iter.clone();
                tmp.push(j);
                ans.push(tmp);
            }
        }
    }
    ans
}


fn main() {
    input!{
        n: usize,
        k: usize,
        adash: [usize; n],
    }
    let mut a = vec![];
    for i in 0..n {
        a.push(adash[i] - 1);
    }
    let mut flag = vec![0; n];
    let mut start = 0;
    let mut goal = 0;
    let mut loopstart = 0;
    let mut loopend = 0;
    let mut loopflag = 0;
    let mut looplist = Vec::new();
    let mut i = 0;
    while i < k {
        goal = a[start];
        start = goal;
        flag[goal] = flag[goal] + 1;
        if flag[goal] == 2 {
            loopflag = 1;
            if loopstart == 0 {
                loopstart = i;
            }
        }
        if flag[goal] == 3 {
            loopend = i;
            let tmp = (k-1-i)/(loopend-loopstart);
            i += tmp * (loopend-loopstart);
//            break;
        }
        if loopflag == 1 {
            looplist.push(goal);
        }
        i += 1;
    }
    if loopend > 0 {
        //println!("{}", k%looplist.len());
//        goal = *looplist.get((k-loopstart)%looplist.len()-1).unwrap_or(&goal);
    }
//    println!("{}, {}, {}, {:?}", goal, loopstart, loopend, looplist);
    println!("{}", goal+1);
}


Measured memory_bytes: 8012