#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10, inf = 1e9;
const long double pi = 3.14159265;
int n, answer = inf;
pair<int, int> a[maxn];
map<int, int> cnt, up;
int check(int ind) {
  if (up[a[ind].first] >= (n + 1) / 2) return 0;
  if (up[a[ind].second] >= (n + 1) / 2) return 0;
  if (((n + 1) / 2) - (up[a[ind].first]) <=
      cnt[a[ind].first] - up[a[ind].first]) {
    return ((n + 1) / 2) - (up[a[ind].first]);
  }
  if (((n + 1) / 2) - (up[a[ind].second]) <=
      cnt[a[ind].second] - up[a[ind].second]) {
    return ((n + 1) / 2) - (up[a[ind].second]);
  }
  return -1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    cnt[a[i].first]++, cnt[a[i].second]++;
    up[a[i].first]++;
    if (a[i].first == a[i].second) cnt[a[i].first]--;
  }
  for (int i = 0; i < n; i++) {
    if (check(i) != -1) answer = min(answer, check(i));
  }
  if (answer == inf) answer = -1;
  cout << answer;
  return 0;
}
