#include <bits/stdc++.h>
using namespace std;
int N;
map<int, int> numFront, numBack, totalNum;
int main() {
  int res = 1 << 30;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    int front, back;
    scanf("%d %d", &front, &back);
    numFront[front]++;
    numBack[back]++;
    if (numFront.find(back) == numFront.end()) numFront[back] = 0;
    if (numBack.find(front) == numBack.end()) numBack[front] = 0;
    if (front == back)
      totalNum[front]++;
    else {
      totalNum[front]++;
      totalNum[back]++;
    }
  }
  map<int, int>::iterator it1 = numFront.begin();
  map<int, int>::iterator it2 = numBack.begin();
  map<int, int>::iterator it3 = totalNum.begin();
  while (it1 != numFront.end()) {
    int frontCnt = it1->second;
    int backCnt = it2->second;
    int totalCnt = it3->second;
    int half = (N % 2) ? (N / 2 + 1) : (N / 2);
    int coincide = frontCnt + backCnt - totalCnt;
    int flipNeeded = max(0, half - frontCnt);
    if (flipNeeded <= backCnt - coincide) {
      res = min(res, flipNeeded);
    }
    it1++;
    it2++;
    it3++;
  }
  if (res == 1 << 30)
    printf("%d\n", -1);
  else
    printf("%d\n", res);
  return 0;
}
