#include <bits/stdc++.h>
namespace Helper {
using LL = long long;
const int MAXN = 1e5 + 1;
const int MOD = 1e9 + 7;
const LL INF = 1e18 * 1LL;
template <typename T>
void PrintVector(std::vector<T> v) {
  for (typename std::vector<T>::iterator it = v.begin(); it != v.end(); it++) {
    std::cout << *it << " ";
  }
}
auto Max = [](int &x, int &y) -> void {
  if (x < y) {
    x = y;
  }
  y = 0;
};
};  // namespace Helper
void initializeMain() { std::ios::sync_with_stdio(false); }
int N;
std::pair<int, int> a[Helper::MAXN];
std::map<int, int> lhs, rhs, other;
int main() {
  initializeMain();
  std::cin >> N;
  int total = (int)(N / 2) + N % 2;
  bool ind = false;
  for (int i = 1; i <= N; i++) {
    std::cin >> a[i].first >> a[i].second;
    if (++lhs[a[i].first] >= total) {
      ind = true;
    }
    if (a[i].first != a[i].second) {
      ++rhs[a[i].second];
    }
  }
  if (ind) {
    return std::cout << 0, 0;
  }
  other = rhs;
  Helper::LL mn = 1e18;
  for (int i = 1; i <= N; i++) {
    if (rhs[a[i].first] > 0 && a[i].first != a[i].second) {
      if (lhs[a[i].first] + rhs[a[i].first] >= total) {
        mn = std::min(mn, (total - lhs[a[i].first]) * 1LL);
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    if (rhs[a[i].second] > 0 && a[i].first != a[i].second) {
      if (lhs[a[i].second] + rhs[a[i].second] >= total) {
        mn = std::min(mn, (total - lhs[a[i].second]) * 1LL);
      }
    }
  }
  if (mn == 1e18) {
    std::cout << -1;
  } else {
    std::cout << mn;
  }
  return 0;
}
