#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
int MMOD(string a,int mmod)
{
    int len=a.length();
    int t=0;
    for( int i = 0; i < len; i++ )
    {
        t*=10;
        t+=a[i]-'0';
        if( t >= mmod )
            t=t%mmod;
    }
    return t;
}
bool comp(string a,string b){
    if(a==b)return true;
    if(a.size()>b.size())return true;
    else if(b.size()>a.size())return false;
    else return a>b;
}
string sub(string a,string b){
    bool minus=0;
    if(!comp(a,b)){
        swap(a,b);
        minus=1;
    }
    int maxlen=max(a.size(),b.size());
    vector<int> ret(maxlen,0);
    string ans="";
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    for(int i=0;i<a.size();i++){
        ret[i]=a[i]-'0';
    }
    for(int i=0;i<b.size();i++){
        ret[i]-=b[i]-'0';
    }
    for(int i=0;i<maxlen;i++){
        while(ret[i]<0){
            ret[i]+=10;
            ret[i+1]--;
        }
        ans+=(ret[i]+'0');
    }
    reverse(ans.begin(),ans.end());
    int cnt=0;
    while(ans[cnt]=='0'&&cnt!=ans.size()-1)cnt++;
    return (minus?"-":"")+ans.substr(cnt);
}
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n,a;cin>>n;
    a=0;
    string kk;cin>>kk;
    ll k;
    
    V<ll>b(n);
    for(ll i=0;i<n;i++){
        cin>>b[i];
        b[i]--;
        //cout<<b[i]<<endl;
    }
    ll cnt=0;
    V<ll>loop;
    loop.pb(a);
    map<ll,ll>m;
    m[a]++;
    cnt++;
    ll now=b[a];
    ll alr=0;
    while(m[now]==0){
        cnt++;
        m[now]=cnt;
        loop.pb(now);
        //cout<<now<<endl;
        now=b[now];
        if(m[now]){
            alr = m[now]-1;
        }
    }
    bool abc=0;
    if(kk.length()<=18){
        k=stoll(kk);
        if(k<=alr){
            cout<<loop[k]+1<<endl;abc=1;
        }
    }
    if(abc==0){
        string ssub=to_string(alr);
        kk=sub(kk,ssub);
            //cout<<ssub<<Endl;
            //cout<<kk<<" "<<cnt<<Endl;
        k=MMOD(kk,cnt-alr);
            //cout<<k<<endl;
        cout<<loop[alr+k]+1<<endl;
    }
    
    
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































Measured memory_bytes: 18624