#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  map<long long int, long long int> maximos_colores_front;
  map<long long int, long long int> maximos_colores_back;
  map<long long int, long long int> ambos;
  for (int i = 0; i < n; i++) {
    long long int a, b;
    cin >> a >> b;
    if (a == b) {
      if (ambos.find(a) == ambos.end())
        ambos.insert(make_pair(a, 1));
      else
        ambos[a]++;
    }
    if (maximos_colores_front.find(a) == maximos_colores_front.end())
      maximos_colores_front.insert(make_pair(a, 1));
    else
      maximos_colores_front[a]++;
    if (maximos_colores_back.find(b) == maximos_colores_back.end())
      maximos_colores_back.insert(make_pair(b, 1));
    else
      maximos_colores_back[b]++;
  }
  long long int mini = n;
  for (auto it : maximos_colores_front) {
    long long int x =
        it.second + maximos_colores_back[it.first] - ambos[it.first];
    if (x >= (n + 1) / 2) {
      mini = min(max((n + 1) / 2 - it.second, 0ll), mini);
    }
  }
  for (auto it : maximos_colores_back) {
    long long int x =
        it.second + maximos_colores_front[it.first] - ambos[it.first];
    if (x >= (n + 1) / 2) {
      mini = min(min(it.second - ambos[it.first], (n + 1) / 2), mini);
    }
  }
  if (mini == n)
    cout << -1 << endl;
  else
    cout << mini << endl;
  return 0;
}
