#include <bits/stdc++.h>
using namespace std;
int a, t, m, o = 10000009;
map<int, int> l, g;
pair<int, int> p[100009];
int main() {
  cin >> a;
  for (int i = 1; i <= a; i++) {
    cin >> p[i].first >> p[i].second;
    if (p[i].first == p[i].second)
      l[p[i].first]++;
    else
      l[p[i].first]++, g[p[i].second]++;
  }
  if (a % 2 == 0)
    t = a / 2;
  else
    t = a / 2 + 1;
  m = t;
  for (int i = 1; i <= a; i++) {
    t = m;
    if (l[p[i].first] + g[p[i].first] >= t) {
      if (l[p[i].first] > t)
        t = 0;
      else
        t -= l[p[i].first];
      if (t >= 0 && o > t) o = t;
    }
    if (g[p[i].second] >= t && g[p[i].second] < o) o = t;
  }
  if (o != 10000009)
    cout << o << " ";
  else
    cout << -1 << " ";
  return 0;
}
