#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 6;
long long a[N], b[N], mod[N];
struct cinema {
  string st;
  int i, pt;
} llist[N];
bool cmp(cinema A, cinema B) {
  if (A.i == B.i) return A.pt > B.pt;
  return A.i < B.i;
}
int main() {
  long long n, m, i, p, id, k, mn = LLONG_MAX, sum = 0;
  scanf("%lld", &n);
  map<long long, int> fr, ba;
  for (i = 1; i <= n; i++) {
    long long x, y;
    scanf("%lld %lld", &x, &y);
    a[i] = x, b[i] = y;
    fr[x]++;
    if (x != y) ba[y]++;
    if (fr[x] >= ((n + 1) >> 1)) {
      puts("0");
      return 0;
    }
  }
  long long ck = (1 + n) >> 1;
  for (i = 1; i <= n; i++) {
    if (fr[a[i]] + ba[a[i]] >= ck) {
      mn = min((long long)mn, (long long)(ck - fr[a[i]]));
    }
  }
  if (mn == LLONG_MAX) {
    for (int j = 1; j <= n; j++) {
      if (ba[b[j]] >= ck) {
        cout << ck;
        return 0;
      }
    }
    puts("-1");
    return 0;
  }
  cout << mn;
}
