#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 20;
int mp[N * 2], cnt[N * 2], fi[N], se[N], steps[N * 2];
int main() {
  setvbuf(stdout, NULL, _IONBF, 0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> fi[i] >> se[i];
    mp[i * 2] = fi[i], mp[i * 2 + 1] = se[i];
  }
  sort(mp, mp + n * 2);
  unique(mp, mp + n * 2);
  for (int i = 0; i < n; i++) {
    fi[i] = lower_bound(mp, mp + n * 2, fi[i]) - mp;
    se[i] = lower_bound(mp, mp + n * 2, se[i]) - mp;
    cnt[fi[i]]++;
    if (fi[i] != se[i]) cnt[se[i]]++;
    steps[fi[i]]++;
  }
  int ans = n + 1;
  for (int i = 0; i < n * 2; i++) {
    if (cnt[i] >= (n + 1) / 2) ans = min(ans, max(0, (n + 1) / 2 - steps[i]));
  }
  if (ans == n + 1)
    cout << "-1\n";
  else
    cout << ans << '\n';
  return 0;
}
