#include <bits/stdc++.h>
using namespace std;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const long long int Inf = 1LL << 62;
map<int, int> cntup, cntlw, duplicate;
set<int> up, lw;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int x, y, n, need;
  cin >> n;
  need = n / 2 + (n & 1);
  while (n--) {
    cin >> x >> y;
    up.insert(x);
    cntup[x]++;
    lw.insert(y);
    cntlw[y]++;
    if (x == y) {
      duplicate[x]++;
    }
  }
  int ans = 1e9;
  for (int x : up) {
    cntlw[x] -= duplicate[x];
    if (cntup[x] >= need) {
      cout << 0 << endl;
      return 0;
    } else if (cntup[x] + cntlw[x] >= need) {
      ans = min(ans, need - cntup[x]);
    }
    cntlw[x] += duplicate[x];
  }
  for (int x : lw) {
    cntup[x] -= duplicate[x];
    int lagbe = need - cntup[x];
    if (lagbe <= 0) {
      cout << 0 << endl;
      return 0;
    } else if (cntup[x] + cntlw[x] >= need) {
      ans = min(ans, need - cntup[x]);
    }
    cntlw[x] += duplicate[x];
  }
  if (ans == 1e9) {
    ans = -1;
  }
  cout << ans << endl;
  return 0;
}
