#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k;
  int n, m;
  int x, y;
  scanf("%d", &n);
  set<int> colors;
  map<int, int> shoja, ulta;
  for (i = 0; i < n; i++) {
    scanf("%d%d", &x, &y);
    colors.insert(x);
    colors.insert(y);
    shoja[x]++;
    ulta[y]++;
    if (x == y) ulta[x]--;
  }
  int req = (n / 2) + (n % 2);
  int ans = 1e6, hi = n, lo = 0, mid;
  while (lo <= hi) {
    mid = (lo + hi) / 2;
    x = 0;
    set<int>::iterator itr = colors.begin();
    while (itr != colors.end()) {
      k = shoja[*itr] + min(max(0, ulta[*itr]), mid);
      if (k >= req) {
        x = 1;
        break;
      }
      itr++;
    }
    if (x)
      ans = min(ans, mid), hi = mid - 1;
    else
      lo = mid + 1;
  }
  if (ans == 1e6)
    printf("%d", -1);
  else
    printf("%d", ans);
  return 0;
}
