public static void main ( String [ ] args ) throws Exception {
  FastReader sc = new FastReader ( ) ;
  String a = sc . next ( ) , b = sc . next ( ) , c = sc . next ( ) ;
  int cnta [ ] = new int [ 26 ] , cntb [ ] = new int [ 26 ] , cntc [ ] = new int [ 26 ] ;
  for ( int i = 0 ;
  i < a . length ( ) ;
  i ++ ) {
    cnta [ a . charAt ( i ) - 'a' ] ++ ;
  }
  for ( int i = 0 ;
  i < b . length ( ) ;
  i ++ ) {
    cntb [ b . charAt ( i ) - 'a' ] ++ ;
  }
  for ( int i = 0 ;
  i < c . length ( ) ;
  i ++ ) {
    cntc [ c . charAt ( i ) - 'a' ] ++ ;
  }
  int maxb = Integer . MAX_VALUE ;
  for ( int i = 0 ;
  i < 26 ;
  i ++ ) {
    if ( cntb [ i ] == 0 ) continue ;
    maxb = Math . min ( cnta [ i ] / cntb [ i ] , maxb ) ;
  }
  int ansb = 0 , ansc = 0 ;
  for ( int i = 0 ;
  i <= maxb ;
  i ++ ) {
    int cc = Integer . MAX_VALUE ;
    for ( int j = 0 ;
    j < 26 ;
    j ++ ) {
      if ( cntc [ j ] > 0 ) {
        cc = Math . min ( cc , ( cnta [ j ] - i * cntb [ j ] ) / cntc [ j ] ) ;
      }
    }
    if ( ansb + ansc < i + cc ) {
      ansb = i ;
      ansc = cc ;
    }
  }
  StringBuilder sb = new StringBuilder ( ) ;
  ;
}

public static void main ( String [ ] args ) throws Exception { FastReader sc = new FastReader ( ) ; String a = sc . next ( ) , b = sc . next ( ) , c = sc . next ( ) ; int cnta [ ] = new int [ 26 ] , cntb [ ] = new int [ 26 ] , cntc [ ] = new int [ 26 ] ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { cnta [ a . charAt ( i ) - ' a ' ] ++ ; } for ( int i = 0 ; i < b . length ( ) ; i ++ ) { cntb [ b . charAt ( i ) - ' a ' ] ++ ; } for ( int i = 0 ; i < c . length ( ) ; i ++ ) { cntc [ c . charAt ( i ) - ' a ' ] ++ ; } int maxb = Integer . MAX_VALUE ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( cntb [ i ] == 0 ) continue ; maxb = Math . min ( cnta [ i ] / cntb [ i ] , maxb ) ; } int ansb = 0 , ansc = 0 ; for ( int i = 0 ; i <= maxb ; i ++ ) { int cc = Integer . MAX_VALUE ; for ( int j = 0 ; j < 26 ; j ++ ) { if ( cntc [ j ] > 0 ) { cc = Math . min ( cc , ( cnta [ j ] - i * cntb [ j ] ) / cntc [ j ] ) ; } } if ( ansb + ansc < i + cc ) { ansb = i ; ansc = cc ; } } StringBuilder sb = new StringBuilder ( ) ; ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_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))) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) 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) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal)))) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal)))) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) 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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (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))))))) (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 (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))))))) (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 (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))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (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: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (continue_statement)) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))) (identifier))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) 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 (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (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: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))) right: (array_access array: (identifier) index: (identifier))))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list))))))