#include <bits/stdc++.h>
using namespace std;
int N;
map<int, int> table1, table2, table3;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    table1[a]++;
    table2[b]++;
    if (a == b) table3[a]++;
  }
  if (N % 2) N++;
  N /= 2;
  int nMax = INT_MAX;
  for (map<int, int>::iterator itr = table1.begin(); itr != table1.end();
       itr++) {
    int x = itr->second;
    int y = table2[itr->first];
    int z = table3[itr->first];
    if (x + y - z >= N) {
      nMax = min(nMax, N - x);
    }
  }
  for (map<int, int>::iterator itr = table2.begin(); itr != table2.end();
       itr++) {
    int x = itr->second;
    int y = table1[itr->first];
    int z = table3[itr->first];
    if (x + y - z >= N) {
      nMax = min(nMax, N - y);
    }
  }
  if (nMax < 0) nMax = 0;
  if (nMax == INT_MAX) {
    cout << "-1" << endl;
  } else {
    cout << nMax << endl;
  }
  return 0;
}
