static String smallestFreq ( String S1 , String S2 ) {
  HashMap < String , Integer > banned = new HashMap < > ( ) ;
  for ( int i = 0 ;
  i < S2 . length ( ) ;
  i ++ ) {
    String s = "" ;
    while ( i < S2 . length ( ) && S2 . charAt ( i ) != ' ' ) s += S2 . charAt ( i ++ ) ;
    banned . put ( s , banned . get ( s ) == null ? 1 : banned . get ( s ) + 1 ) ;
  }
  HashMap < String , Integer > result = new HashMap < > ( ) ;
  String ans = "" ;
  int freq = 0 ;
  for ( int i = 0 ;
  i < S1 . length ( ) ;
  i ++ ) {
    String s = "" ;
    while ( i < S1 . length ( ) && S1 . charAt ( i ) != ' ' ) s += S1 . charAt ( i ++ ) ;
    if ( banned . get ( s ) == null ) {
      result . put ( s , result . get ( s ) == null ? 1 : result . get ( s ) + 1 ) ;
      if ( result . get ( s ) > freq || ( result . get ( s ) == freq && s . compareTo ( ans ) < 0 ) ) {
        ans = s ;
        freq = result . get ( s ) ;
      }
    }
  }
  return ans ;
}

static String smallestFreq ( String S1 , String S2 ) { HashMap < String , Integer > banned = new HashMap < > ( ) ; for ( int i = 0 ; i < S2 . length ( ) ; i ++ ) { String s = " " ; while ( i < S2 . length ( ) && S2 . charAt ( i ) != ' ▁ ' ) s += S2 . charAt ( i ++ ) ; banned . put ( s , banned . get ( s ) == null ? 1 : banned . get ( s ) + 1 ) ; } HashMap < String , Integer > result = new HashMap < > ( ) ; String ans = " " ; int freq = 0 ; for ( int i = 0 ; i < S1 . length ( ) ; i ++ ) { String s = " " ; while ( i < S1 . length ( ) && S1 . charAt ( i ) != ' ▁ ' ) s += S1 . charAt ( i ++ ) ; if ( banned . get ( s ) == null ) { result . put ( s , result . get ( s ) == null ? 1 : result . get ( s ) + 1 ) ; if ( result . get ( s ) > freq || ( result . get ( s ) == freq && s . compareTo ( ans ) < 0 ) ) { ans = s ; freq = result . get ( s ) ; } } } return ans ; }
(method_declaration (modifiers) type: (type_identifier) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier)) (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (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: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)))) body: (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (update_expression (identifier))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (ternary_expression condition: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (null_literal)) consequence: (decimal_integer_literal) alternative: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (decimal_integer_literal)))))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)))) body: (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (update_expression (identifier))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (null_literal))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (ternary_expression condition: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (null_literal)) consequence: (decimal_integer_literal) alternative: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (identifier)) right: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (identifier)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (decimal_integer_literal)))))) consequence: (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 (identifier))))))))))) (return_statement (identifier))))