#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int main() {
  map<int, int> m, p;
  int n;
  cin >> n;
  for (int i = (1); i <= (n); i++) {
    int u, v;
    cin >> u >> v;
    m[u]++;
    if (v != u) p[v]++;
  }
  int ans = 1e9;
  if (n % 2) n++;
  for (auto i : m) {
    int cval = i.second;
    int poss = p[i.first];
    int reqd = n / 2;
    int now = reqd - cval;
    if (now <= poss) ans = min(ans, max(0, now));
  }
  for (auto i : p) {
    int poss = i.second;
    int cval = m[i.first];
    int reqd = n / 2;
    int now = reqd - cval;
    if (now <= poss) ans = min(ans, max(0, now));
  }
  if (ans == 1e9)
    cout << "-1\n";
  else
    cout << ans << endl;
  return 0;
}
