#include <bits/stdc++.h>
using namespace std;
const int maxn = 100022;
int n;
int f[maxn];
int b[maxn];
map<int, int> a, c;
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> f[i] >> b[i];
    ++a[f[i]];
    if (f[i] != b[i]) ++c[b[i]];
  }
  int ans = 1e7;
  for (int i = 0; i < n; ++i) {
    if (a[f[i]] >= n / 2 + n % 2) {
      ans = 0;
      break;
    }
    if (c[b[i]] >= n / 2 + n % 2) ans = min(ans, n / 2 + n % 2);
    if (a[f[i]] + c[f[i]] >= n / 2 + n % 2)
      ans = min(ans, n / 2 + n % 2 - a[f[i]]);
  }
  if (ans < 1e7)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}
