
Module Module1

    Sub main()
        Dim user2 As List(Of String) = New List(Of String)(Split(Console.ReadLine(), " "))
        Dim countryMax As Long = user2(0)
        Dim terepoMax As UInt64 = user2(1)
        Dim user3 As List(Of String) = New List(Of String)(Split(Console.ReadLine(), " "))
        Dim towns As New List(Of Long)(Array.ConvertAll(user3.ToArray, Function(i As String) CLng(i)))

        Dim nextTown As Long = 0
        Dim worpCount = 0

        Dim checkPoint As New List(Of Long)

        checkPoint.Add(0)   ' 初期位置を訪れた場所に追加

        Do
            nextTown = towns(nextTown) - 1
            worpCount += 1

            ' 既に訪れているか
            If checkPoint.Contains(towns(nextTown)) Then
                terepoMax = worpCount + (terepoMax Mod worpCount) +1
            End If
            checkPoint.Add(nextTown)    '移動先を訪れた場所に追加
        Loop While terepoMax > worpCount

        Console.WriteLine(towns(nextTown))
    End Sub
end module