#include <bits/stdc++.h>
using namespace std;
struct g {
  int f, b;
} a[110000];
int q[110000], b[110000], cp[110000], cb[110000];
bool cmp(g &x, g &y) { return x.f < y.f; }
bool cmp2(g &x, g &y) { return x.b < y.b || x.b == y.b && x.f < y.f; }
int main() {
  int h, l, r, i, flag = 0, j, h1, n, ans = 10000000;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d%d", &a[i].f, &a[i].b);
  a[n].f = a[n].b = -1000;
  sort(a, a + n, cmp);
  h = 0;
  for (i = 0; i < n; i++) cp[i] = cb[i] = 1;
  for (i = 0; i < n; i++) {
    if (a[i].f == a[i + 1].f) {
      q[h] = a[i].f;
      cp[h]++;
    } else {
      q[h] = a[i].f;
      h++;
    }
  }
  h1 = 0;
  sort(a, a + n, cmp2);
  for (i = 0; i < n; i++) {
    if (a[i].b == a[i + 1].b) {
      b[h1] = a[i].b;
      cb[h1]++;
      if (a[i].b == a[i].f) cb[h1]--;
    } else {
      b[h1] = a[i].b;
      if (a[i].b == a[i].f) cb[h1]--;
      h1++;
    }
  }
  for (i = 0; i < h; i++) {
    if (cp[i] >= n / 2 + n % 2) {
      flag = 1;
      ans = 0;
      break;
    }
    l = 0;
    r = h1 - 1;
    while (r - l > 1) {
      if (b[(l + r) / 2] >= q[i])
        r = (l + r) / 2;
      else
        l = (l + r) / 2;
    }
    if (b[l] == q[i]) {
      if (cb[l] + cp[i] >= n / 2 + n % 2 && n / 2 + n % 2 - cp[i] < ans) {
        flag = 1;
        ans = n / 2 + n % 2 - cp[i];
      }
    }
    if (b[r] == q[i]) {
      if (cb[r] + cp[i] >= n / 2 + n % 2 && n / 2 + n % 2 - cp[i] < ans) {
        flag = 1;
        ans = n / 2 + n % 2 - cp[i];
      }
    }
  }
  if (flag)
    printf("%d\n", ans);
  else {
    for (i = 0; i < h1; i++) {
      if (cb[i] >= n / 2 + n % 2) {
        ans = n / 2 + n % 2;
        flag = 1;
      }
    }
    if (flag)
      printf("%d\n", ans);
    else
      printf("-1\n");
  }
}
