#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(ll i = a; i < (n); ++i)
#define repD(i, a, n) for(ll i = a; i > (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (long long) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
// #define mp make_pair
#define pb push_back
// #define endl "\n"
#define MAXN 5000000
const long double PI = 3.141592653589793238462643383;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<double> vd;
typedef vector<pii> vii;
int Ceil(int a, int b){
    if(a%b==0) return a/b;
    else return (a/b)+1;
}
ll p=1000000007;
float E = 0.00000000000001;
ll power(ll x, ll y){
    if(y==0){
        return 1;
    }
    if(y%2==0){
        ll q=power(x,y/2);
        q=q%p;
        return (q*q)%p;
    }
    ll q=power(x,y/2);
    q=q%p;
    return ((x%p)*((q*q)%p))%p; 
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}

bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}  

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a); 
}
long long int mod(long long int a, long long int b) {
    long long int ret = a%b; return ret>=0? ret: ret+b; 
}


long long int rec(long long int num, vector <long long int> &dp){
        if(num == 1)
            return 0;
        if(dp[num] != -1)
            return dp[num];
        else if(num%2)
            dp[num] = 1 + rec(3*num + 1, dp);
        else
            dp[num] = 1 + rec(num/2, dp);
        return dp[num];
    }
int getKth(int lo, int hi, int k) {
        vector <long long int> dp(10000, -1);
        vector < pair<long long int, long long int> > vec(hi - lo + 1);
        dp[0] = 0;
        dp[1] = 0;
        for(int i = lo ; i <= hi ; i++){
            vec[i - lo].first = rec(i, dp);
            vec[i - lo].second = i;
        }
        sort(vec.begin(), vec.end());
            // for(auto x:vec)
            //     cout<<x.second<<" ";
        return vec[k-1].second;
    }

void helper(vector<int> &und, vector<int> &cost, int index, int curr_cost, int &ans, int &x, vector<vector<int>> &a){
    // if(index == cost.size())
    //     return;
    int flag = 1;
    for(auto y:und)
        if(y < x)
            flag = 0;
    if(flag){
        // cout<<"Y";
        ans = min(ans, curr_cost);
        return;
    }
    for(int i = index ; i < cost.size() ; i++){
        int m = a[i].size();
        for(int j = 0 ; j < m ; j++)
            und[j] += a[i][j];
        helper(und, cost, i+1, curr_cost + cost[i], ans, x, a);
        for(int j = 0 ; j < m ; j++)
            und[j] -= a[i][j];
    }
}
int main(){

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);   
    freopen("output.txt", "w", stdout);
    #endif

    int t;
    // cin>>t;
    t = 1;
    while(t--){
            int n;
            long long k;
            cin>>n>>k;
            vector<int> a(n+1);
            for(int i = 1 ; i <= n ; i++){
                // int num;
                cin>>a[i];
                // a[i] = num-1;
                // cin>>(a[i]-1);
            }
            unordered_set<int> s;
            int i = 1;
            int entry;
            while(s.find(i) == s.end()){
                s.insert(i);
                i = a[i];
                entry = i;
            }
            i = 1;
            int offset = 0;
            while(i != entry){
                offset++;
                i = a[i];
            }
            int cycle = 1;
            i = a[i];
            while(i != entry){
                cycle++;
                i = a[i];
            }
            // int ans;
            long long temp = k;
            k -= min(k,(long long)offset);
            if(k == 0){
                // cout<<"Y";
                int i = 1;
                while(temp > 0){
                    // cout<<i<<" ";
                    i = a[i];
                    temp--;
                }
                cout<<i;
                return 0;
            }
            k = k%cycle;
            while(k > 0){
                entry = a[entry];
                k--;
            }
            cout<<entry;
        }   
        return 0;
    }

Measured memory_bytes: 12160