#include <bits/stdc++.h>
using namespace std;
void divideByZero(const char *error) {
  printf(error);
  fclose(stdout);
  int a = 234;
  a = a / (a - a);
}
long parseLong() {
  long temp;
  scanf("%ld", &temp);
  return temp;
}
int main() {
  long n;
  scanf("%ld", &n);
  map<long, long> up, down;
  for (long i = 0; i < n; i++) {
    long tUp, tDown;
    scanf("%ld %ld", &tUp, &tDown);
    if (up.find(tUp) == up.end()) up[tUp] = 0;
    if (up.find(tDown) == up.end()) up[tDown] = 0;
    if (down.find(tUp) == down.end()) down[tUp] = 0;
    if (down.find(tDown) == down.end()) down[tDown] = 0;
    up[tUp] = 1 + up[tUp];
    if (tUp != tDown) down[tDown] = 1 + down[tDown];
  }
  vector<long> keys;
  for (map<long, long>::iterator it = up.begin(); it != up.end(); it++)
    keys.push_back(it->first);
  long ans = -1;
  for (vector<long>::iterator key = keys.begin(); key != keys.end(); key++) {
    if (2 * (up[*key] + down[*key]) < n) continue;
    long val = max(0L, (n - 2 * up[*key] + 1) / 2);
    ans = ans < 0 ? val : min(ans, val);
  }
  printf("%ld", ans);
  return 0;
}
