public static void main ( String [ ] args ) {
  FastReader in = new FastReader ( ) ;
  PrintWriter out = new PrintWriter ( System . out ) ;
  int n = in . nextInt ( ) ;
  HashSet < Integer > set = new HashSet < Integer > ( ) ;
  HashMap < Integer , Integer > fTotal = new HashMap < > ( ) ;
  HashMap < Integer , Integer > fUp = new HashMap < > ( ) ;
  HashMap < Integer , Integer > same = new HashMap < > ( ) ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    int up = in . nextInt ( ) , down = in . nextInt ( ) ;
    set . add ( up ) ;
    set . add ( down ) ;
    add ( fUp , up ) ;
    add ( fTotal , up ) ;
    add ( fTotal , down ) ;
    if ( up == down ) add ( same , up ) ;
  }
  int ans = n ;
  for ( int ele : set ) {
    int cnt = fUp . getOrDefault ( ele , 0 ) ;
    if ( cnt >= ( n + 1 ) / 2 ) {
      ans = 0 ;
      break ;
    }
    int cntTot = fTotal . get ( ele ) ;
    int cntSame = same . getOrDefault ( ele , 0 ) ;
    if ( cntTot - cntSame >= ( n + 1 ) / 2 ) ans = Math . min ( ( ( n + 1 ) / 2 ) - cnt , ans ) ;
  }
  out . println ( ans == n ? - 1 : ans ) ;
  out . close ( ) ;
}

public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = in . nextInt ( ) ; HashSet < Integer > set = new HashSet < Integer > ( ) ; HashMap < Integer , Integer > fTotal = new HashMap < > ( ) ; HashMap < Integer , Integer > fUp = new HashMap < > ( ) ; HashMap < Integer , Integer > same = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int up = in . nextInt ( ) , down = in . nextInt ( ) ; set . add ( up ) ; set . add ( down ) ; add ( fUp , up ) ; add ( fTotal , up ) ; add ( fTotal , down ) ; if ( up == down ) add ( same , up ) ; } int ans = n ; for ( int ele : set ) { int cnt = fUp . getOrDefault ( ele , 0 ) ; if ( cnt >= ( n + 1 ) / 2 ) { ans = 0 ; break ; } int cntTot = fTotal . get ( ele ) ; int cntSame = same . getOrDefault ( ele , 0 ) ; if ( cntTot - cntSame >= ( n + 1 ) / 2 ) ans = Math . min ( ( ( n + 1 ) / 2 ) - cnt , ans ) ; } out . println ( ans == n ? - 1 : ans ) ; out . close ( ) ; }
(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)))) (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: (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)))) (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: (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: (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: (identifier)) 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))) 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 (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (enhanced_for_statement type: (integral_type) name: (identifier) value: (identifier) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (break_statement))) (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)))) consequence: (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal))) right: (identifier)) (identifier)))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (ternary_expression condition: (binary_expression left: (identifier) right: (identifier)) consequence: (unary_expression operand: (decimal_integer_literal)) alternative: (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))