#include <bits/stdc++.h>
using namespace std;
vector<int> E;
int main(int argc, char** argv) {
  int n;
  cin >> n;
  map<int, int> cntu, cntd, cnto;
  int fg = 0;
  for (int i = 1; i <= n; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    if (l != r) {
      cntu[l]++;
      cntd[r]++;
    } else
      cnto[l]++;
    E.push_back(l);
    E.push_back(r);
    if (cntd[l] + cntu[l] + cnto[l] >= n / 2 + n % 2) fg = 1;
    if (cntd[r] + cntu[r] + cnto[r] >= n / 2 + n % 2) fg = 1;
  }
  if (!fg) {
    printf("-1");
    return 0;
  }
  int ans = 1e9;
  for (int i = 0; i <= E.size() - 1; i++) {
    int nd = n / 2 + n % 2 - cntu[E[i]] - cnto[E[i]];
    if (nd <= cntd[E[i]]) {
      ans = min(ans, max(0, min(cntd[E[i]], nd)));
    }
  }
  cout << ans;
  return 0;
}
