#include <bits/stdc++.h>
using namespace std;
map<int64_t, int> mp1, mp2;
int fnc(int n) {
  int ans = n + 1;
  for (auto i = mp1.begin(); i != mp1.end(); i++) {
    if (i->second >= (n + 1) / 2) return 0;
    if (i->second + mp2[i->first] >= ((n + 1) / 2))
      ans = min(ans, (n + 1) / 2 - i->second);
  }
  if (ans < n) return ans;
  for (auto i = mp2.begin(); i != mp2.end(); i++) {
    if (i->second >= (n + 1) / 2) return (n + 1) / 2;
  }
  if (ans > n) return -1;
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int m;
  cin >> m;
  int64_t a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    mp1[a]++;
    if (a != b) mp2[b]++;
  }
  cout << fnc(m) << endl;
  return 0;
}
