public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  String linha = sc . nextLine ( ) ;
  int k = sc . nextInt ( ) ;
  sc . nextLine ( ) ;
  int [ ] ocorrencias = new int [ 26 ] ;
  for ( int i = 0 ;
  i < 26 ;
  i ++ ) ocorrencias [ i ] = i ;
  for ( int i = 0 ;
  i < linha . length ( ) ;
  i ++ ) ocorrencias [ linha . charAt ( i ) - 'a' ] += GAMBI ;
  Arrays . sort ( ocorrencias ) ;
  int j = 0 , aux ;
  while ( k > 0 && j < 26 ) {
    aux = ( ocorrencias [ j ] - ( ocorrencias [ j ] % GAMBI ) ) / GAMBI ;
    if ( aux > k ) {
      ocorrencias [ j ] -= k * GAMBI ;
      k = 0 ;
    }
    else {
      ocorrencias [ j ] -= aux * GAMBI ;
      k -= aux ;
      j ++ ;
    }
  }
  int [ ] ocorrencias2 = new int [ 26 ] ;
  for ( int i = 0 ;
  i < 26 ;
  i ++ ) ocorrencias2 [ ocorrencias [ i ] % GAMBI ] = ( ocorrencias [ i ] - ( ocorrencias [ i ] % GAMBI ) ) / GAMBI ;
  aux = 0 ;
  for ( int i = 0 ;
  i < 26 ;
  i ++ ) if ( ocorrencias2 [ i ] > 0 ) aux ++ ;
  System . out . println ( aux ) ;
  for ( int i = 0 ;
  i < linha . length ( ) ;
  i ++ ) {
    if ( ocorrencias2 [ linha . charAt ( i ) - 'a' ] > 0 ) {
      System . out . print ( linha . charAt ( i ) ) ;
      ocorrencias2 [ linha . charAt ( i ) - 'a' ] -- ;
    }
  }
  System . out . print ( "\n" ) ;
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String linha = sc . nextLine ( ) ; int k = sc . nextInt ( ) ; sc . nextLine ( ) ; int [ ] ocorrencias = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) ocorrencias [ i ] = i ; for ( int i = 0 ; i < linha . length ( ) ; i ++ ) ocorrencias [ linha . charAt ( i ) - ' a ' ] += GAMBI ; Arrays . sort ( ocorrencias ) ; int j = 0 , aux ; while ( k > 0 && j < 26 ) { aux = ( ocorrencias [ j ] - ( ocorrencias [ j ] % GAMBI ) ) / GAMBI ; if ( aux > k ) { ocorrencias [ j ] -= k * GAMBI ; k = 0 ; } else { ocorrencias [ j ] -= aux * GAMBI ; k -= aux ; j ++ ; } } int [ ] ocorrencias2 = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) ocorrencias2 [ ocorrencias [ i ] % GAMBI ] = ( ocorrencias [ i ] - ( ocorrencias [ i ] % GAMBI ) ) / GAMBI ; aux = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) if ( ocorrencias2 [ i ] > 0 ) aux ++ ; System . out . println ( aux ) ; for ( int i = 0 ; i < linha . length ( ) ; i ++ ) { if ( ocorrencias2 [ linha . charAt ( i ) - ' a ' ] > 0 ) { System . out . print ( linha . charAt ( i ) ) ; ocorrencias2 [ linha . charAt ( i ) - ' a ' ] -- ; } } System . out . print ( " \n " ) ; }
(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: (type_identifier) 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)))) (expression_statement (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 (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: (decimal_integer_literal)) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) right: (identifier)))) (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)) declarator: (variable_declarator name: (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))))) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (identifier) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))) alternative: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (identifier) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (update_expression (identifier))))))) (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 (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: (decimal_integer_literal)) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) right: (binary_expression left: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))))) right: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (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: (decimal_integer_literal)) update: (update_expression (identifier)) body: (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (expression_statement (update_expression (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) right: (decimal_integer_literal))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (expression_statement (update_expression (array_access array: (identifier) index: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal))))))