#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  map<long long, long long> front, back, same, nums;
  for (typeof(n) i = 0; i < (n); ++i) {
    long long a, b;
    cin >> a >> b;
    front[a]++;
    back[b]++;
    nums[a] = 1;
    nums[b] = 1;
    if (a == b) same[a]++;
  }
  long long mmax = -1;
  bool found = false;
  for (typeof((nums).begin()) it = (nums).begin(); it != (nums).end(); ++it) {
    if (front[it->first] + back[it->first] - same[it->first] >= (n + 1) / 2) {
      mmax = max(front[it->first], mmax);
      found = true;
    }
  }
  if (!found) {
    cout << -1 << endl;
  } else {
    cout << max(0LL, (n + 1) / 2 - mmax) << endl;
  }
  return 0;
}
