#include <bits/stdc++.h>
using namespace std;
map<int, int> mymap;
int n, a[100010], b[100010];
int solve(int c) {
  int cnt = 0, ret = 0;
  for (int i = 0; i < n; i++)
    if (a[i] == c) cnt++;
  for (int i = 0; i < n && cnt < (n + 1) / 2; i++)
    if (a[i] != c && b[i] == c) ret++, cnt++;
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    mymap[a[i]]++;
    if (b[i] != a[i]) mymap[b[i]]++;
  }
  vector<int> cand;
  for (map<int, int>::iterator it = mymap.begin(); it != mymap.end(); it++)
    if (it->second >= (n + 1) / 2) cand.push_back(it->first);
  int ans = 0x3f3f3f3f;
  for (int i = 0; i < int(cand.size()); i++) {
    ans = min(ans, solve(cand[i]));
  }
  if (ans == 0x3f3f3f3f) ans = -1;
  printf("%d\n", ans);
  return 0;
}
