#include <bits/stdc++.h>
using namespace std;
map<int, int> s, t;
struct ps {
  int a, c;
  bool operator<(const struct ps& a) const { return c > a.c; }
} q[200000];
int sc;
int main() {
  int n, i, half;
  scanf("%d", &n);
  half = (n & 1) ? n / 2 + 1 : n / 2;
  for (i = 0; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a != b) t[b]++;
    s[a]++;
  }
  for (map<int, int>::iterator i = s.begin(); i != s.end(); i++) {
    q[sc].a = i->first;
    q[sc++].c = i->second;
  }
  sort(q, q + sc);
  for (i = 0; i < sc; i++) {
    if (q[i].c >= half) {
      printf("%d\n", 0);
      return 0;
    }
    if (q[i].c + t[q[i].a] >= half) {
      printf("%d\n", half - q[i].c);
      return 0;
    }
  }
  for (map<int, int>::iterator i = t.begin(); i != t.end(); i++) {
    if (i->second >= half) {
      printf("%d\n", half);
      return 0;
    }
  }
  printf("%d\n", -1);
  return 0;
}
