#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  map<int, int> front, back, both;
  set<int> s;
  const int m = (n + 1) / 2;
  for (int i = 0; i < n; i++) {
    int f, b;
    cin >> f >> b;
    front[f]++;
    back[b]++;
    if (f == b) both[f]++;
    s.insert(f);
    s.insert(b);
  }
  int res = INT_MAX;
  for (auto &x : s) {
    if (front[x] >= m) {
      res = 0;
    } else if (front[x] + back[x] - both[x] >= m) {
      res = min(res, m - front[x]);
    }
  }
  if (res == INT_MAX) res = -1;
  cout << res << '\n';
}
