#include <bits/stdc++.h>
using namespace std;
istream &in = cin;
int h;
int n;
int fb[2][100001];
map<int, int> m[3];
int main() {
  in >> n;
  h = (n + 1) / 2;
  for (int i = 0; i < n; ++i) in >> fb[0][i] >> fb[1][i];
  for (int i = 0; i < n; ++i) {
    if (fb[0][i] == fb[1][i])
      m[2][fb[0][i]]++;
    else
      m[0][fb[0][i]]++, m[1][fb[1][i]]++;
  }
  int ret = 1000000001;
  for (int i = 0; i < n; ++i) {
    int cn = fb[0][i], f = m[0][cn], b = m[1][cn], s = m[2][cn];
    if (f + s >= h)
      ret = 0;
    else if (f + s + b >= h)
      ret = min(ret, h - f - s);
    cn = fb[1][i];
    if (m[0][cn] || m[2][cn]) continue;
    b = m[1][cn];
    if (b >= h) ret = min(ret, h);
  }
  if (ret == 1000000001)
    cout << -1 << endl;
  else
    cout << ret << endl;
  return 0;
}
