#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2000;
int N;
map<int, int> OpenCards, CloseCards;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    OpenCards[a]++;
    CloseCards[b]++;
    if (a == b) CloseCards[b]--;
  }
  pair<int, int> opt(2000000000, 2000000000);
  int Q = (N + 1) / 2;
  for (map<int, int>::iterator it = OpenCards.begin(); it != OpenCards.end();
       it++)
    if (OpenCards[it->first] + CloseCards[it->first] >= Q)
      opt = min(opt, make_pair(Q - it->second, it->first));
  for (map<int, int>::iterator it = CloseCards.begin(); it != CloseCards.end();
       it++)
    if (OpenCards[it->first] + CloseCards[it->first] >= Q)
      opt =
          min(opt, make_pair(max(min(it->second, Q - OpenCards[it->first]), 0),
                             it->first));
  if (opt.first == 2000000000)
    cout << -1 << endl;
  else
    cout << max(opt.first, 0) << endl;
  return 0;
}
