#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:20000000")
using namespace std;
int ri() {
  int x;
  scanf("%d", &x);
  return x;
}
long long rll() {
  long long x;
  scanf("%lld", &x);
  return x;
}
map<int, int> u;
map<int, int> d;
map<int, int> omg;
void solve() {
  int n = ri();
  set<int> st;
  for (int i = (int)(1); i <= (int)(n); i++) {
    int x = ri(), y = ri();
    u[x]++, d[y]++;
    if (x == y) omg[x]++;
  }
  int need = (n + 1) / 2;
  int best = 2e9;
  map<int, int>::iterator it;
  for (it = u.begin(); it != u.end(); it++) st.insert(it->first);
  for (it = d.begin(); it != d.end(); it++) st.insert(it->first);
  set<int>::iterator it1;
  for (it1 = st.begin(); it1 != st.end(); it1++) {
    int t1, t2, t3 = omg[*it1];
    t1 = u[*it1];
    t2 = d[*it1];
    if (t1 + t2 - t3 < need) continue;
    if (t1 >= need)
      best = 0;
    else
      best = min(best, (need - t1));
  }
  if (best == 2e9)
    cout << -1 << endl;
  else
    cout << best << endl;
}
int main() {
  solve();
  return 0;
}
