#include <bits/stdc++.h>
using namespace std;
long long x, y;
struct node {
  long long color, num;
} a[200010] = {0};
long long b[200010] = {0};
long long both[200010] = {0};
map<long long, long long> maps;
bool cmp(node &q, node &w) { return q.num > w.num; }
int main() {
  long long i, j, l, n, m, t, k, ss;
  long long color = 1;
  scanf("%lld", &n);
  if (n % 2 == 0)
    ss = n / 2;
  else
    ss = n / 2 + 1;
  for (i = 1; i <= n; i++) {
    scanf("%lld", &x);
    scanf("%lld", &y);
    if (maps[x] == 0) {
      maps[x] = color;
      color++;
    }
    if (maps[y] == 0) {
      maps[y] = color;
      color++;
    }
    if (x == y) {
      both[maps[x]]++;
    } else {
      a[maps[x]].num++;
      b[maps[y]]++;
    }
  }
  for (i = 1; i <= color; i++) a[i].color = i;
  sort(a + 1, a + color, cmp);
  long long ans = 0x3f3f3f3f3f;
  for (i = 1; i < color; i++) {
    k = a[i].num;
    k += both[a[i].color];
    k += b[a[i].color];
    if (k >= ss) {
      ans = min(ans, ss - a[i].num - both[a[i].color]);
    }
  }
  if (ans == 0x3f3f3f3f3f)
    printf("-1");
  else if (ans <= 0)
    printf("0");
  else
    printf("%lld", ans);
  return 0;
}
