#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
map<int, int> m;
int a[maxn], b[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    if (a[i] != b[i]) m[b[i]]++;
    m[a[i]]++;
  }
  vector<int> v;
  for (map<int, int>::iterator it = m.begin(); it != m.end(); ++it)
    if (it->second >= (n + 1) / 2) v.push_back(it->first);
  int ans = n + 1;
  for (int i = 0; i < v.size(); i++) {
    int x = v[i];
    int tmp = (n + 1) / 2;
    for (int j = 0; j < n; j++)
      if (a[j] == x) tmp--;
    tmp = max(tmp, 0);
    if (tmp < ans) ans = tmp;
  }
  if (ans > n)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
