#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c = 100000000, d, i, j, n, m;
  map<int, int> vis1, vis2;
  vector<int> v1, v2;
  cin >> n;
  v1.resize(n);
  v2.resize(n);
  for (i = 0; i < n; i++) {
    cin >> v1[i] >> v2[i];
    if (v1[i] != v2[i])
      vis1[v1[i]]++, vis2[v2[i]]++;
    else
      vis1[v1[i]]++;
  }
  for (i = 0; i < n; i++) {
    a = vis1[v1[i]];
    if (a >= (n + 1) / 2) {
      c = min(c, 0);
      break;
    } else if (a + vis2[v1[i]] >= (n + 1) / 2)
      c = min(((n + 1) / 2) - a, c);
    else if (vis2[v2[i]] >= (n + 1) / 2)
      c = min((n + 1) / 2, c);
  }
  if (c > n)
    cout << -1 << endl;
  else
    cout << c << endl;
  return 0;
}
