#include <bits/stdc++.h>
using namespace std;
long long n;
map<long long, long long> up, down, same;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long a, b;
    cin >> a >> b;
    up[a]++;
    down[b]++;
    if (a == b) same[a]++;
  }
  long long store = (n + 1) / 2;
  long long ans = 1e9;
  for (auto &it : up) {
    long long cur = it.second;
    long long reqd = max(0LL, store - it.second);
    if (reqd == 0) return cout << "0", 0;
    if (down.find(it.first) != down.end()) {
      long long have = down[it.first] - same[it.first];
      if (have >= reqd) ans = min(ans, reqd);
    }
  }
  for (auto &it : down) {
    if (it.second >= store) ans = min(ans, store);
  }
  if (ans == 1e9) ans = -1;
  cout << ans;
  return 0;
}
