#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& fout, const vector<T>& vec) {
  for (size_t i = 0; i < vec.size(); ++i) {
    fout << vec[i] << ' ';
  }
  return fout;
}
int main() {
  int n;
  cin >> n;
  map<int, int> cc;
  vector<pair<int, int>> in(n);
  for (int i = 0; i < int(n); ++i) {
    cin >> in[i].first >> in[i].second;
    cc[in[i].first]++;
    cc[in[i].second]++;
  }
  vector<pair<int, int>> buf;
  for (const auto& el : cc) {
    buf.push_back(make_pair(el.second, el.first));
  }
  sort((buf).begin(), (buf).end());
  reverse((buf).begin(), (buf).end());
  vector<int> candidates;
  long long nd = n / 2 + n % 2;
  for (const auto& el : buf) {
    if (el.first >= nd) {
      candidates.push_back(el.second);
    }
  }
  long long mx = 1000000000;
  for (const auto& col : candidates) {
    long long can = 0, cur = 0;
    for (size_t i = 0; i < in.size(); ++i) {
      if (in[i].first == col) {
        cur++;
      } else if (in[i].second == col) {
        can++;
      }
    }
    if (can + cur >= nd) {
      mx = min(mx, max(0LL, nd - cur));
    }
  }
  if (mx == 1000000000) {
    cout << -1 << endl;
  } else {
    cout << mx << endl;
  }
}
