#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int>> c(n);
  map<int, int> cnt;
  for (int i = 0; i < n; i++) {
    int f, b;
    scanf("%d %d", &f, &b);
    c[i] = pair<int, int>{f, b};
    cnt[f]++;
    if (f != b) cnt[b]++;
  }
  int ans = n + 1;
  for (auto v : cnt)
    if (v.second >= (n + 1) / 2) {
      int tmp = 0;
      for (int i = 0; i < n; i++)
        if (c[i].first == v.first) tmp++;
      ans = min(ans, max(0, (n + 1) / 2 - tmp));
    }
  printf("%d\n", ans > n ? -1 : ans);
  return 0;
}
