#include <bits/stdc++.h>
using namespace std;
template <class T>
bool up_max(T& a, const T& b) {
  return b > a ? a = b, 1 : 0;
}
template <class T>
bool up_min(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
int n, v[100020 + 100020], num[100020 + 100020];
pair<int, int> c[100020];
int solve(int first) {
  int s = 0;
  for (int i = 1; i <= n; ++i)
    if (c[i].first == first) ++s;
  int ans = (n + 1) / 2 - s;
  if (ans < 0) ans = 0;
  return ans;
}
int main() {
  while (cin >> n) {
    int i, first, second, N = 0;
    for (i = 1; i <= n; ++i) {
      scanf("%d%d", &first, &second);
      v[++N] = first, v[++N] = second;
      c[i] = pair<int, int>(first, second);
    }
    sort(v + 1, v + 1 + N);
    N = unique(v + 1, v + 1 + N) - v - 1;
    for (i = 1; i <= n; ++i) {
      c[i].first = lower_bound(v + 1, v + 1 + N, c[i].first) - v;
      c[i].second = lower_bound(v + 1, v + 1 + N, c[i].second) - v;
    }
    fill(num, num + 1 + N, 0);
    for (i = 1; i <= n; ++i) {
      if (c[i].first != c[i].second)
        num[c[i].first]++, num[c[i].second]++;
      else
        num[c[i].first]++;
    }
    vector<int> Q;
    for (i = 1; i <= N; ++i)
      if (num[i] >= (n + 1) / 2) Q.push_back(i);
    if (Q.empty()) {
      puts("-1");
      continue;
    }
    int ans = 10000000;
    for (i = 0; i < Q.size(); ++i) up_min(ans, solve(Q[i]));
    cout << ans << endl;
  }
}
