#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
int aa[100001];
int bb[100001];
int n;
int bsa(int arg) {
  int ans = 0;
  if (aa[0] > arg) return ans;
  int l = 0, r = n - 1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (aa[mid] <= arg) {
      ans = max(ans, mid);
      l = mid + 1;
    } else
      r = mid - 1;
  }
  return ans + 1;
}
int bsb(int arg) {
  int ans = 0;
  if (bb[0] > arg) return ans;
  int l = 0, r = n - 1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (bb[mid] <= arg) {
      ans = max(ans, mid);
      l = mid + 1;
    } else
      r = mid - 1;
  }
  return ans + 1;
}
int main() {
  int m, ans = inf;
  cin >> n;
  m = (n + 1) / 2;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    aa[i] = a;
    a == b ? bb[i] = -1 : bb[i] = b;
  }
  sort(aa, aa + n);
  sort(bb, bb + n);
  for (int i = 0; i < n; ++i) {
    if (i > 0 && aa[i] == aa[i - 1]) continue;
    int a = bsa(aa[i]) - bsa(aa[i] - 1);
    int b = bsb(aa[i]) - bsb(aa[i] - 1);
    if (a >= m) {
      ans = 0;
      cout << ans;
      return 0;
    } else {
      if (b >= m - a) ans = min(ans, m - a);
    }
  }
  for (int i = 0; i < n; ++i) {
    if ((i > 0 && bb[i] == bb[i - 1]) || bb[i] == -1) continue;
    int b = bsb(bb[i]) - bsb(bb[i] - 1);
    if (b >= m) {
      ans = min(ans, m);
    }
  }
  cout << (ans == inf ? -1 : ans);
  return 0;
}
