#include <bits/stdc++.h>
using namespace std;
template <typename F, typename S>
ostream &operator<<(ostream &os, const pair<F, S> &p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  typename vector<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  os << "[";
  typename set<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename F, typename S>
ostream &operator<<(ostream &os, const map<F, S> &v) {
  os << "[";
  typename map<F, S>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
long long dx[4] = {1, -1, 0, 0};
long long dy[4] = {0, 0, 1, -1};
const long long N = 5, M = 1e2 + 5, mod = 998244353, MOD = 1e9 + 7, inf = 5e17,
                MAXN = 1e6 + 5;
string alphabet = "abcdefghijklmnopqrstuvwxyz",
       capital = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", dig = "0123456789";
void solve(long long tt) {
  long long m, k, i, n, j;
  map<long long, long long> faceUp;
  map<long long, long long> faceDown;
  long long ans = inf;
  cin >> n;
  for (i = 0; i < n; i++) {
    long long f, b;
    cin >> f >> b;
    if (f == b)
      faceUp[f]++;
    else
      faceUp[f]++, faceDown[b]++;
  }
  ++n;
  for (auto z : faceUp) {
    long long curr = z.second;
    long long now;
    if (curr + faceDown[z.first] < (n / 2)) continue;
    long long ex = max(0LL, n / 2 - curr);
    ans = min(ex, ans);
  }
  for (auto z : faceDown) {
    long long now = faceUp[z.first];
    long long req = max(0LL, n / 2 - now);
    if (req > z.second) continue;
    ans = min(req, ans);
  }
  if (ans == inf) ans = -1;
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long i;
  long long T = 1;
  for (auto blockTime = make_pair(chrono::high_resolution_clock::now(), true);
       blockTime.second;
       fprintf(stderr, "%s: %d ms\n", "Exec Time : ",
               (long long)chrono::duration_cast<chrono::milliseconds>(
                   chrono::high_resolution_clock::now() - blockTime.first)
                   .count()),
            fflush(stderr), blockTime.second = false) {
    long long x = 1;
    while (x <= T) {
      solve(x);
      x++;
    }
  }
  return 0;
}
