#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[100001], b[100001];
  cin >> n;
  int t = (n / 2) + (n % 2);
  map<int, int> l;
  map<int, int> r;
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &a[i], &b[i]);
    l[a[i]]++;
    if (a[i] != b[i]) {
      r[b[i]]++;
    }
  }
  int ans = 10000001;
  for (int i = 1; i <= n; ++i) {
    if (l[a[i]] >= t)
      ans = 0;
    else if (l[a[i]] + r[a[i]] >= t) {
      if (t - l[a[i]] < ans) {
        ans = t - l[a[i]];
      }
    } else if (l[b[i]] == 0 && r[b[i]] >= t) {
      if (t < ans) ans = t;
    }
  }
  if (ans == 10000001) ans = -1;
  cout << ans << endl;
  return 0;
}
