#include <bits/stdc++.h>
using namespace std;
struct node {
  int f, b;
} card[300000];
struct CCOL {
  int num, col;
} res[300000];
int resNo;
int n;
map<int, int> mp;
map<int, int>::iterator p;
int INF = 1000000000;
int min(int a, int b) { return a < b ? a : b; }
int getans(int col) {
  int i, j;
  int ans = 0;
  int f = 0;
  for (i = 0; i < n; i++) {
    if (card[i].f == col || card[i].b == col) ans++;
    if (card[i].f == col) f++;
  }
  if (ans < (n + 1) / 2) return INF;
  if (f >= (n + 1) / 2) return 0;
  return (n + 1) / 2 - f;
}
int cmp(CCOL a, CCOL b) { return a.num > b.num; }
int main() {
  int i, j;
  while (scanf("%d", &n) != EOF) {
    mp.clear();
    for (i = 0; i < n; i++) {
      scanf("%d%d", &card[i].f, &card[i].b);
      mp[card[i].f]++;
      mp[card[i].b]++;
    }
    resNo = 0;
    for (p = mp.begin(); p != mp.end(); p++) {
      res[resNo].col = p->first;
      res[resNo++].num = p->second;
    }
    sort(res, res + resNo, cmp);
    int ans = INF;
    for (i = 0; i < resNo; i++) {
      if (res[i].num < (n + 1) / 2) break;
      ans = min(ans, getans(res[i].col));
    }
    if (ans == INF)
      printf("-1\n");
    else
      printf("%d\n", ans);
  }
  return 0;
}
