#include <bits/stdc++.h>
const int inf = 0x7FFFFFFF;
using namespace std;
map<long long, int> cnt;
map<long long, int>::iterator it;
int front[100010], back[100010];
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &front[i], &back[i]);
    if (front[i] != back[i]) {
      cnt[front[i]]++;
      cnt[back[i]]++;
    } else {
      cnt[front[i]]++;
    }
  }
  int ans = inf;
  for (it = cnt.begin(); it != cnt.end(); it++) {
    int x = it->second;
    if (x * 2 < N) continue;
    int f = 0;
    for (int i = 0; i < N; i++) {
      if (front[i] == it->first) f++;
    }
    if (f * 2 < N)
      ans = min(ans, (N + 1) / 2 - f);
    else {
      ans = 0;
      break;
    }
  }
  if (ans == inf) ans = -1;
  printf("%d\n", ans);
  return 0;
}
