#include <bits/stdc++.h>
using namespace std;
map<int, int> ms;
map<int, int> mr;
map<int, int> ml;
int main(void) {
  int n;
  while (~scanf("%d", &n)) {
    ms.clear();
    mr.clear();
    ml.clear();
    for (int i = 0; i < n; ++i) {
      int l, r;
      scanf("%d%d", &l, &r);
      ml[l]++;
      mr[r]++;
      ms[l]++;
      ms[r]++;
      if (l == r) ms[l]--;
    }
    int ot = n;
    int minn = 0x7fffffff;
    if (n % 2)
      ot = n / 2 + 1;
    else
      ot = n / 2;
    map<int, int>::iterator p;
    for (p = ms.begin(); p != ms.end(); p++) {
      if (p->second >= ot) {
        if (ml[p->first] >= ot) {
          minn = 0;
          break;
        } else {
          minn = min(minn, ot - ml[p->first]);
        }
      }
    }
    if (minn != 0x7fffffff) {
      printf("%d\n", minn);
    } else {
      printf("-1\n");
    }
  }
  return 0;
}
