#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, mx = 0;
  cin >> n;
  map<int, long long int> mp1, mp2;
  map<pair<long long int, long long int>, int> mp;
  vector<long long int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a[i] = x, b[i] = y;
    mp1[x]++, mp2[y]++;
    mp[{a[i], b[i]}]++;
    mx = max(mx, mp2[y]);
  }
  long long int operations = INT_MAX;
  for (int i = 0; i < n; i++) {
    long long int temp = mp1[a[i]] + mp2[a[i]] - mp[{a[i], a[i]}];
    if (temp >= (n + 1) / 2) {
      operations =
          min(operations, max(min(temp, (n + 1) / 2) - mp1[a[i]], 0LL));
    }
  }
  if (operations == INT_MAX && mx < (n + 1) / 2) {
    cout << "-1\n";
    return 0;
  }
  if (operations == INT_MAX) {
    operations = (n + 1) / 2;
  }
  cout << operations << endl;
}
