#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 23;
const int MOD = 1e9 + 9;
const int N = 2e5 + 10;
map<int, int> up;
map<int, int> back;
map<int, int> both;
set<int> nrs;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    if (a == b)
      ++both[a];
    else
      ++up[a], ++back[b];
    nrs.insert(a);
    nrs.insert(b);
  }
  int need = (n + 1) / 2;
  int ans = INF;
  for (auto nr : nrs) {
    if (up[nr] + back[nr] + both[nr] < need) continue;
    int steps = max(0, need - up[nr] - both[nr]);
    ans = min(ans, steps);
  }
  if (ans == INF) ans = -1;
  cout << ans << '\n';
}
