#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
unordered_map<int, int> d, s;
unordered_map<int, bool> used;
pair<int, int> a[N];
int n;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    d[a[i].first]++;
    s[a[i].second]++;
    if (a[i].first == a[i].second) s[a[i].second]--;
  }
  int k = 0;
  for (int i = 0; i < n; i++) {
    k = max(k, d[a[i].first] + s[a[i].second]);
  }
  if (k < (n + 1) / 2) {
    cout << -1;
    return 0;
  }
  int ans = 10 * N;
  int c;
  int need = (n + 1) / 2;
  for (int i = 0; i < n; i++) {
    c = a[i].first;
    if (!used[c]) {
      if (s[c] >= need - d[c]) ans = min(ans, max(0, need - d[c]));
    }
    c = a[i].second;
    if (!used[c]) {
      if (s[c] >= need - d[c]) ans = min(ans, max(0, need - d[c]));
    }
  }
  if (ans == 10 * N) ans = -1;
  cout << ans;
  return 0;
}
