#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int n;
int main() {
  int i, j;
  int u, v;
  while (~scanf("%d", &n)) {
    map<int, int> a;
    map<int, int> b;
    int ans = inf;
    for (i = 0; i < n; i++) {
      scanf("%d%d", &u, &v);
      if (u != v) a[u]++;
      a[v]++;
      b[u]++;
      if (a[u] >= (n + 1) / 2) ans = min(ans, max(0, (n + 1) / 2 - b[u]));
      if (a[v] >= (n + 1) / 2) ans = min(ans, max(0, (n + 1) / 2 - b[v]));
    }
    if (ans > n)
      printf("-1\n");
    else
      printf("%d\n", ans);
  }
  return 0;
}
