#include <bits/stdc++.h>
using namespace std;
int a[100009];
int b[100009];
int main() {
  int i, j, k, n, m, d, x, y;
  while (cin >> n) {
    int ans = 100000000;
    map<int, int> f, s;
    map<int, int>::iterator it;
    for (i = 0; i < n; i++) {
      cin >> x >> y;
      a[i] = x;
      b[i] = y;
      f[x]++;
      if (x != y) s[y]++;
    }
    int p = n / 2;
    if (n & 1) p++;
    for (it = f.begin(); it != f.end(); it++) {
      int co1 = it->second;
      int v1 = it->first;
      if (co1 >= p) {
        ans = 0;
        continue;
      }
      if (s[v1] + co1 >= p) ans = min(ans, p - co1);
    }
    f.clear();
    s.clear();
    for (i = 0; i < n; i++) {
      f[b[i]]++;
      if (a[i] != b[i]) s[a[i]]++;
    }
    for (it = f.begin(); it != f.end(); it++) {
      int cnt = it->second;
      int v = it->first;
      if (cnt >= p) {
        ans = min(ans, p);
        continue;
      }
      if (s[v] + cnt >= p) ans = min(ans, cnt);
    }
    if (ans == 100000000)
      puts("-1");
    else
      cout << ans << endl;
  }
  return 0;
}
