#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int MAXN = 1e5 + 1, MODM = 1e9 + 7;
map<int, int> q;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<pair<int, int> > a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    q[a[i].first]++;
    if (a[i].second != a[i].first) q[a[i].second]++;
  }
  bool fl = 0;
  set<int> may;
  for (int i = 0; i < n; i++) {
    if (q[a[i].first] >= (n + 1) / 2) may.insert(a[i].first);
    if (q[a[i].second] >= (n + 1) / 2) may.insert(a[i].second);
  }
  if (may.size() == 0) {
    cout << -1;
    return 0;
  }
  int ans = MODM;
  for (auto now : may) {
    int cnt = 0;
    int PP = 0;
    for (int i = 0; i < n; i++) {
      cnt += (a[i].first == now);
    }
    for (int i = 0; i < n; i++) {
      if (a[i].first != now) {
        if (cnt >= (n + 1) / 2)
          break;
        else if (a[i].second == now) {
          ++PP;
          ++cnt;
        }
      }
    }
    ans = min(PP, ans);
  }
  cout << ans;
  return 0;
}
