#include <bits/stdc++.h>

using namespace std;

#define endl "\n"
#define F first
#define S second
#define PB push_back
#define int long long

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;

const int maxn = 1e5;
const int OO = 1e18;
const int mod = 1e9 + 7;
const int maxp = 64;

int32_t main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);

    int n,k;
    cin >> n >> k;
    int a[n+1][maxp];
    memset(a,-1,sizeof(a));

    for(int i=1;i<=n;i++)
        cin >> a[i][0];

    for(int i=1;i<maxp;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(a[j][i-1] != -1)
            a[j][i] = a[a[j][i-1]][i-1];
        }
    }
    int y = 1;
    for(int i=0;i<maxp;i++)
    {
     
        if(k & (1<<i))
        {
            y = a[y][i];
        }
    }

    cout << y;
	return 0;
}
