#include <bits/stdc++.h>
using namespace std;
struct pi {
  int x, o, p;
} c[222222];
int z[222222], f[222222];
bool cp1(pi x, pi y) { return x.p < y.p; }
bool cp2(pi x, pi y) { return x.o < y.o; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &c[i * 2].p, &c[i * 2 + 1].p);
    c[i * 2].o = i * 2;
    c[i * 2 + 1].o = i * 2 + 1;
  }
  sort(c, c + n * 2, cp1);
  int tp = 0;
  for (int i = 0; i < n * 2; i++) {
    if (i == 0 || c[i].p != c[i - 1].p)
      c[i].x = ++tp;
    else
      c[i].x = tp;
  }
  sort(c, c + n * 2, cp2);
  for (int i = 0; i < n * 2; i += 2) {
    z[c[i].x]++;
    if (c[i].x != c[i + 1].x) f[c[i + 1].x]++;
  }
  int ans = 100001;
  for (int i = 1; i <= tp; i++) {
    if (z[i] * 2 >= n)
      ans = 0;
    else {
      if ((z[i] + f[i]) * 2 >= n) {
        ans = min(ans, (n + 1) / 2 - z[i]);
      }
    }
  }
  printf("%d\n", ans < 100001 ? ans : -1);
  return 0;
}
