public static void main ( String [ ] args ) {
  Scanner scanner = new Scanner ( System . in ) ;
  int N = scanner . nextInt ( ) ;
  int a = scanner . nextInt ( ) - 1 ;
  BigInteger k = scanner . nextBigInteger ( ) ;
  int [ ] b = new int [ N ] ;
  for ( int i = 0 ;
  i < N ;
  i ++ ) b [ i ] = scanner . nextInt ( ) - 1 ;
  int n = 0 ;
  int i1 = a ;
  int i2 = a ;
  do {
    i1 = b [ i1 ] ;
    i2 = b [ b [ i2 ] ] ;
    n ++ ;
  }
  while ( i1 != i2 ) ;
  int m = 0 ;
  int i3 = a ;
  while ( i1 != i3 ) {
    i1 = b [ i1 ] ;
    i3 = b [ i3 ] ;
    m ++ ;
  }
  int l ;
  if ( k . compareTo ( BigInteger . valueOf ( m ) ) < 0 ) {
    l = k . intValue ( ) ;
  }
  else {
    l = m + k . subtract ( BigInteger . valueOf ( m ) ) . mod ( BigInteger . valueOf ( n ) ) . intValue ( ) ;
  }
  while ( l > 0 ) {
    a = b [ a ] ;
    l -- ;
  }
  System . out . println ( a + 1 ) ;
}

public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int a = scanner . nextInt ( ) - 1 ; BigInteger k = scanner . nextBigInteger ( ) ; int [ ] b = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) b [ i ] = scanner . nextInt ( ) - 1 ; int n = 0 ; int i1 = a ; int i2 = a ; do { i1 = b [ i1 ] ; i2 = b [ b [ i2 ] ] ; n ++ ; } while ( i1 != i2 ) ; int m = 0 ; int i3 = a ; while ( i1 != i3 ) { i1 = b [ i1 ] ; i3 = b [ i3 ] ; m ++ ; } int l ; if ( k . compareTo ( BigInteger . valueOf ( m ) ) < 0 ) { l = k . intValue ( ) ; } else { l = m + k . subtract ( BigInteger . valueOf ( m ) ) . mod ( BigInteger . valueOf ( n ) ) . intValue ( ) ; } while ( l > 0 ) { a = b [ a ] ; l -- ; } System . out . println ( a + 1 ) ; }
(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: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) (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 (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: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal))))) (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: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (do_statement body: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (array_access array: (identifier) index: (identifier))))) (expression_statement (update_expression (identifier)))) condition: (parenthesized_expression (binary_expression left: (identifier) right: (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: (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) (expression_statement (update_expression (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) name: (identifier) arguments: (argument_list))))))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) (expression_statement (update_expression (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))))))