#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000000")
using namespace std;
int main() {
  long long int n, a;
  cin >> n;
  map<long long int, long long int> good;
  map<long long int, long long int> det;
  vector<pair<long long int, long long int> > op(n);
  for (long long int i = 0; i < n; i++) {
    cin >> a >> op[i].second;
    op[i].first = a;
    good[a]++;
    if (good[a] >= (n / 2 + (n & 1))) {
      cout << 0;
      return 0;
    }
  }
  long long int ans = 1e18;
  for (long long int i = 0; i < n; i++) {
    a = op[i].second;
    if (a == op[i].first) continue;
    good[a]++;
    det[a]++;
    if (good[a] >= (n / 2 + (n & 1))) {
      ans = min(ans, det[a]);
    }
  }
  cout << (ans == 1e18 ? -1 : ans);
}
