public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  long N = sc . nextLong ( ) ;
  long a = sc . nextLong ( ) ;
  String k = sc . next ( ) ;
  long [ ] b = new long [ ( int ) N ] ;
  for ( int i = 0 ;
  i < N ;
  i ++ ) {
    b [ i ] = sc . nextLong ( ) ;
  }
  ArrayList < Long > f = new ArrayList < Long > ( ) ;
  f . add ( a ) ;
  long presence = a ;
  long s = 0 ;
  long g = 1 ;
  for ( int i = 0 ;
  i < N ;
  i ++ ) {
    presence = b [ ( int ) presence - 1 ] ;
    if ( f . contains ( presence ) ) {
      for ( int j = 0 ;
      j < N ;
      j ++ ) {
        if ( f . get ( j ) == presence ) {
          s = ( long ) j ;
          g = ( long ) ( i + 1 ) - s ;
          break ;
        }
      }
      break ;
    }
    else {
      f . add ( presence ) ;
    }
  }
  long ans = 0 ;
  if ( k . length ( ) <= 6 ) {
    int step = Integer . parseInt ( k ) ;
    int p = ( int ) a ;
    for ( int i = 0 ;
    i < step ;
    i ++ ) {
      p = ( int ) b [ p - 1 ] ;
    }
    ans = p ;
  }
  else {
    long r = 0 ;
    if ( k . length ( ) <= 18 ) {
      r = ( Long . parseLong ( k ) ) % g ;
    }
    else {
      for ( int i = 0 ;
      i < k . length ( ) ;
      i ++ ) {
        long d = Long . parseLong ( String . valueOf ( k . charAt ( i ) ) ) ;
        r = ( 10 * r + d ) % g ;
      }
    }
    while ( r < s ) {
      r += g ;
    }
    ans = f . get ( ( int ) r ) ;
  }
  System . out . println ( ans ) ;
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; String k = sc . next ( ) ; long [ ] b = new long [ ( int ) N ] ; for ( int i = 0 ; i < N ; i ++ ) { b [ i ] = sc . nextLong ( ) ; } ArrayList < Long > f = new ArrayList < Long > ( ) ; f . add ( a ) ; long presence = a ; long s = 0 ; long g = 1 ; for ( int i = 0 ; i < N ; i ++ ) { presence = b [ ( int ) presence - 1 ] ; if ( f . contains ( presence ) ) { for ( int j = 0 ; j < N ; j ++ ) { if ( f . get ( j ) == presence ) { s = ( long ) j ; g = ( long ) ( i + 1 ) - s ; break ; } } break ; } else { f . add ( presence ) ; } } long ans = 0 ; if ( k . length ( ) <= 6 ) { int step = Integer . parseInt ( k ) ; int p = ( int ) a ; for ( int i = 0 ; i < step ; i ++ ) { p = ( int ) b [ p - 1 ] ; } ans = p ; } else { long r = 0 ; if ( k . length ( ) <= 18 ) { r = ( Long . parseLong ( k ) ) % g ; } else { for ( int i = 0 ; i < k . length ( ) ; i ++ ) { long d = Long . parseLong ( String . valueOf ( k . charAt ( i ) ) ) ; r = ( 10 * r + d ) % g ; } } while ( r < s ) { r += g ; } ans = f . get ( ( int ) r ) ; } System . out . println ( ans ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (cast_expression type: (integral_type) value: (identifier)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier))) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (binary_expression left: (cast_expression type: (integral_type) value: (identifier)) right: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (cast_expression type: (integral_type) value: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (identifier)))) (break_statement))))) (break_statement)) alternative: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (cast_expression type: (integral_type) value: (identifier)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (cast_expression type: (integral_type) value: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) (expression_statement (assignment_expression left: (identifier) right: (identifier)))) alternative: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) right: (identifier))))) alternative: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (identifier)) right: (identifier))) right: (identifier)))))))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (cast_expression type: (integral_type) value: (identifier)))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))