#include <bits/stdc++.h>
using namespace std;
void reop_func(const char *in) { freopen(in, "r", stdin); }
int main() {
  ("in.txt");
  int n = 0, ans = 1e9, c1 = 0, c2 = 0, lim = 0;
  scanf("%d", &n), lim = n % 2 ? n / 2 + 1 : n / 2;
  map<int, int> cnt1, cnt2;
  set<int> e;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &c1, &c2);
    if (c1 != c2)
      cnt1[c1]++, cnt2[c2]++, e.insert(c1), e.insert(c2);
    else
      cnt1[c1]++, e.insert(c1);
  }
  for (set<int>::iterator it = e.begin(); it != e.end(); it++) {
    c1 = cnt1[*it], c2 = cnt2[*it];
    if (c1 + c2 < lim) continue;
    if (c1 > lim)
      ans = 0;
    else
      ans = min(ans, lim - c1);
  }
  printf("%d\n", ans == 1e9 ? -1 : ans);
  return 0;
}
