#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mp;
map<long long, long long> mp2;
pair<long long, long long> g[200100];
int main() {
  int n, i, j = 0;
  long long o, p, max1, k;
  cin >> n;
  for (i = 0; i < n; i++) {
    scanf("%I64d", &o);
    mp2[o]++;
    scanf("%I64d", &p);
    if (p != o) mp[p]++;
  }
  if (n % 2 != 0) {
    n++;
  }
  max1 = 0;
  for (map<long long, long long>::iterator it = mp2.begin(); it != mp2.end();
       it++) {
    g[j].first = it->second;
    g[j].second = it->first;
    j++;
  }
  sort(g, g + j, greater<pair<long long, long long> >());
  for (i = 0; i < j; i++) {
    max1 = g[i].first;
    if (max1 + mp[g[i].second] >= n / 2) {
      if (max1 >= n / 2) {
        cout << "0";
        return 0;
      } else {
        cout << n / 2 - max1;
        return 0;
      }
    }
  }
  max1 = 0;
  for (map<long long, long long>::iterator it = mp.begin(); it != mp.end();
       it++) {
    if (it->second > max1) {
      max1 = it->second;
    }
  }
  if (max1 >= n / 2) {
    cout << n / 2;
    return 0;
  }
  cout << "-1";
  return 0;
}
