#include <bits/stdc++.h>
using namespace std;
struct card {
  int x, y, number;
};
bool comp(card c1, card c2) {
  if (c1.x != c2.x)
    if (c1.x < c2.x)
      return true;
    else
      return false;
  else {
    if (c1.number > c2.number) return true;
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  vector<card> vec;
  for (int i = 0; i < n; i++) {
    int x, y, number;
    number = i;
    cin >> x >> y;
    card c;
    c.x = x;
    c.y = y;
    c.number = 1;
    vec.push_back(c);
    c.x = y;
    c.y = x;
    if (c.x != c.y) c.number = 0;
    vec.push_back(c);
  }
  sort(vec.begin(), vec.end(), comp);
  int flip = 0;
  int db = 0;
  int min = 1000000000;
  int count = 1;
  if (vec[0].x == vec[0].y) db++;
  if (vec[0].number == 0) flip++;
  for (int i = 1; i < 2 * n; i++)
    if (vec[i].x == vec[i - 1].x) {
      count++;
      if (vec[i].number == 0)
        flip++;
      else {
        if (vec[i].x == vec[i].y) db++;
      }
      if ((count - db / 2) * 2 >= n && flip < min) min = flip;
    } else {
      count = 1;
      if (vec[i].x == vec[i].y)
        db = 1;
      else
        db = 0;
      if (vec[i].number == 0)
        flip = 1;
      else
        flip = 0;
    }
  if (n == 2 || n == 1) {
    cout << 0;
    return 0;
  }
  if (min != 1000000000)
    cout << min;
  else
    cout << -1;
  return 0;
}
