#include <bits/stdc++.h>
using namespace std;
unordered_map<int, int> a, b, c;
int main() {
  ios::sync_with_stdio(false);
  int n, x, y, z = -1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    a[x]++, b[y]++;
    if (x == y) c[x]++;
  }
  n = (n + 1) / 2;
  for (auto i : a)
    if (i.second + b[i.first] - c[i.first] >= n) z = max(z, i.second);
  for (auto i : b)
    if (i.second >= n) z = max(z, 0);
  if (z == -1)
    cout << z;
  else
    cout << n - min(n, z);
}
