#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 0, 0, 0, 0, 0, 0};
int dy[] = {0, 0, 1, -1, 0, 0, 0, 0};
const long long inf = 100000007;
const double eps = 0.000000009;
long long mod = 1000000007;
map<char, int> m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  pair<long long, long long> a[n];
  for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  map<long long, long long> f;
  for (int i = 0; i < n; i++) {
    if (a[i].first == a[i].second) {
      f[a[i].first]++;
    } else {
      f[a[i].first]++;
      f[a[i].second]++;
    }
  }
  vector<long long> poss;
  long long mi = ceil(1.0 * n / 2.0);
  map<long long, long long>::iterator it = f.begin();
  for (it; it != f.end(); it++) {
    if ((*it).second >= mi) poss.push_back((*it).first);
  }
  if (poss.size() == 0) {
    cout << -1 << endl;
    return 0;
  } else {
    long long ans = inf;
    for (int i = 0; i < poss.size(); i++) {
      long long curr = 0;
      int kk = 0;
      for (int j = 0; j < n; j++) {
        if (poss[i] == a[j].first) {
          kk++;
        }
      }
      for (int j = 0; j < n; j++) {
        if (kk >= mi) break;
        if (poss[i] == a[j].second) {
          kk++;
          curr++;
        }
      }
      ans = min(ans, curr);
    }
    cout << ans << endl;
  }
  return 0;
}
