#include <bits/stdc++.h>
using namespace std;
using pll = pair<long long, long long>;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t, i, x, j, y, z = -1, k, n;
  cin >> n;
  long long a[n], b[n];
  std::map<long long, long long> mf, mb;
  for (i = 0; i < n; i += 1) {
    cin >> a[i] >> b[i];
    mf[a[i]]++;
    if (a[i] != b[i]) mb[b[i]]++;
  }
  z = LLONG_MAX;
  k = (n + 1) / 2;
  for (i = 0; i < n; i += 1) {
    x = a[i];
    t = mf[x];
    if (t >= k) z = 0;
    t += mb[x];
    if (t >= k) z = max(0ll, min(z, k - mf[x]));
    if (a[i] != b[i]) {
      x = b[i];
      t = mb[x];
      if (t >= k) z = min(z, k);
      t += mf[x];
      if (t >= k) z = max(0ll, min(z, k - mf[x]));
    }
    if (z == 0) break;
  }
  if (z == LLONG_MAX) z = -1;
  cout << z << '\n';
}
