#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int mod = 1e9 + 7;
int n, a[N], b[N];
map<int, int> up, down, same;
int main() {
  while (~scanf("%d", &n)) {
    int i, cnt = 0;
    int ans = 0;
    up.clear();
    same.clear();
    down.clear();
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      scanf("%d", &b[i]);
      up[a[i]]++;
      down[b[i]]++;
      if (a[i] == b[i]) same[a[i]]++;
    }
    bool flag = false;
    int nn = n - n / 2;
    for (i = 0; i < n; i++) {
      if (up[a[i]] >= nn) {
        ans = 0;
        flag = true;
        break;
      }
    }
    if (flag)
      cout << ans << endl;
    else {
      ans = n + 1;
      for (i = 0; i < n; i++) {
        int t = up[a[i]] + down[a[i]];
        t -= same[a[i]];
        if (t >= nn) {
          flag = true;
          ans = min(ans, nn - up[a[i]]);
        }
      }
      if (flag)
        cout << ans << endl;
      else {
        ans = n + 1;
        for (i = 0; i < n; i++) {
          if (down[b[i]] >= nn) {
            ans = nn;
            flag = true;
            break;
          }
        }
        if (flag)
          cout << ans << endl;
        else
          cout << -1 << endl;
      }
    }
  }
  return 0;
}
