#include <bits/stdc++.h>
using namespace std;
const int maxint = -1u >> 2;
const double eps = 1e-6;
const int MAX = 100001;
int CA[MAX];
int CB[MAX];
int main() {
  int N;
  cin >> N;
  int ans = N + 1;
  if (N == 1 || N == 2) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> A(N);
  vector<int> B(N);
  map<int, int> MA;
  map<int, int> MB;
  int half = N / 2;
  if (N % 2) half += 1;
  for (int i = 0; i < N; ++i) {
    int a, b;
    cin >> a >> b;
    if (a != b) {
      MB[b] = MB[b] + 1;
    }
    MA[a] = MA[a] + 1;
    if (MA[a] >= half) {
      cout << 0 << endl;
      return 0;
    }
    if (MB[b] >= half) {
      ans = min(ans, MB[b]);
    }
  }
  for (map<int, int>::iterator itr = MA.begin(); itr != MA.end(); ++itr) {
    if (itr->second + MB[itr->first] >= half) {
      ans = min(ans, half - itr->second);
    }
  }
  if (ans == N + 1) {
    cout << -1 << endl;
  } else
    cout << ans << endl;
  return 0;
}
