#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
pair<long long, long long> a[100010];
map<long long, long long> m;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0), cerr << "";
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i].first >> a[i].second, m[a[i].first]++, m[a[i].second]++;
  for (auto it : m)
    if (it.second >= ceil(n * 1.0 / 2)) v.push_back(it.first);
  int ans = 1e9;
  for (int i = 0; i < v.size(); i++) {
    int t1 = 0, t2 = 0;
    for (int j = 0; j < n; j++)
      if (a[j].first == v[i])
        t1++;
      else if (a[j].second == v[i])
        t2++;
    if (t1 >= ceil(n * 1.0 / 2))
      ans = 0;
    else if (t1 + t2 < ceil(n * 1.0 / 2))
      continue;
    else
      ans = min((int)ceil(n * 1.0 / 2) - t1, ans);
  }
  if (ans == 1e9)
    cout << -1;
  else
    cout << ans;
}
