#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

ll pow_f(ll b, ll e) {
    ll ans = 1;
    b = b % M;
    while (e) {
        if (e & 1) {
            ans = (ans * b) % M;
        }
        b = (b * b) % M;
        e >>= 1;
    }
    return ans;
}

ll nCr(ll n, ll r) {
    if (r > n || n < 0 || r < 0) {
        return 0;
    }
    if (n == r || r == 0) {
        return 1;
    }
    r = min(r, n - r);
    ll ans = 1;
    for (ll i = 1; i <= r; ++i) {
        ans = (ans * (n - i + 1)) / (i);
    }
    return ans;
}

ll nCr(tuple<ll, ll> t) {
    auto n = get<0>(t);
    auto k = get<1>(t);
    return nCr(n + k - 1, k);
}

template <typename T>
void print(T v) {
    cout << v << " ";
}

template <typename T>
void print(vector<T> v) {
    for (auto &i : v) {
        print(i);
    }
    cout << endl;
}

void solve() {
    ll n, k;
    cin >> n >> k;

    vector<ll> A(n);
    for (auto &i : A) {
        cin >> i;
    }

    vector<ll> out(3 * n + 2, 0);
    ll start = 1;
    ll idx = 0;
    out[idx] = start;
    map<ll, bool> visited;
    visited[1] = true;

    ll cycleStart = -1;
    ll cycleLength = 0;
    ll cycle = 0;
    ll straight = 0;
    bool firstTime = true;
    bool secondTime = true;

    while (idx < 3 * n + 1) {
        ++idx;
        start = A[start - 1];
        out[idx] = start;

        if (!visited[start] && firstTime) {
            straight++;
        } else if (visited[start] && firstTime) {
            //cycle entered here
            cycleStart = start;  //start of cycle node
            firstTime = false;
            cycle = 1;
        } else if (start == cycleStart && !firstTime && secondTime) {
            cycleLength = cycle;
            secondTime = false;
        } else if (!firstTime && secondTime) {
            ++cycle;
        }

        visited[start] = true;
    }
    straight = straight - cycleLength + 1;
    //printf("%lld %lld %lld\n", straight, cycleLength, cycleStart);
    if (k >= straight) {
        k = straight + ((k - straight) % cycleLength);
    }

    /**
     * 
     * 1 6 2x 5 3x
     * 
     */
    cout << out[k] << endl;
}

void solve2() {
    //cout << "Binary Lifting..." << endl;

    ll n, k;
    cin >> n >> k;
    vector<ll> A(n);
    for (auto &i : A) {
        cin >> i;
    }

    vector<vector<ll>> par(n, vector<ll>(65));

    for (ll i = 0; i < n; ++i) {
        par[i][0] = A[i] - 1;
    }

    for (ll j = 1; j < 65; ++j) {
        for (ll i = 0; i < n; ++i) {
            par[i][j] = par[par[i][j - 1]][j - 1];
        }
    }

    ll out = 0;
    for (ll it = 0; it <= 63; ++it) {
        if (k&(1LL<<it)) {
            out = par[out][it];
        }
    }

    cout << out+1 << endl;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef D_LOCAL
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve2();

    return 0;
}

Measured memory_bytes: 112500