import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class D {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        int n = in.nextInt();
        // int n = 100000;
        HashSet<Integer> set = new HashSet<Integer>(n * 2 + 10);
        TreeMap<Integer, colors> map = new TreeMap<Integer, colors>();
        ArrayList<Integer> all = new ArrayList<Integer>(n * 2 + 100);

        for (int i = 0; i < n; i++) {
            in.hasNext();
            int c1 = in.nextInt(), c2 = in.nextInt();
            // int c1 = (int) (Math.random() * 1000000000), c2 = (int) (Math
            // .random() * 1000000000);
            colors c;
            if ((c = map.get(c1)) != null) {
                c.currSide++;
            } else {
                c = new colors(c1);
                c.currSide++;
                map.put(c1, c);
                all.add(c1);
                set.add(c1);
            }

            if ((c = map.get(c1)) != null) {
                if (c1 != c2)
                    c.OtherSide++;
            } else {
                c = new colors(c2);
                c.OtherSide++;
                map.put(c2, c);
                all.add(c2);
                set.add(c2);
            }
        }

        int res = 9999999, min = n / 2 + (n % 2 == 0 ? 0 : 1);

        for (Map.Entry<Integer, colors> entry : map.entrySet()) {
            colors c = entry.getValue();
            if (c.currSide >= min) {
                System.out.println(0);
                System.exit(0);
            }
            if (c.currSide + c.OtherSide >= min)
                res = Math.min(res, min - c.currSide);
        }

        if (res == 9999999)
            System.out.println(-1);
        else
            System.out.println(res);
    }

    static class colors {
        int c, currSide, OtherSide;

        public colors(int C) {
            c = C;
        }
    }

    static class InputReader {
        BufferedReader buff;
        StringTokenizer tok;
        String cur;

        public InputReader() throws IOException {
            buff = new BufferedReader(new InputStreamReader(System.in));
            tok = new StringTokenizer(cur = buff.readLine());
        }

        public boolean hasNext() throws IOException {
            if (!tok.hasMoreElements()) {
                cur = buff.readLine();
                if (cur == null)
                    return false;
                tok = new StringTokenizer(cur);
            }
            return true;
        }

        public String next() throws IOException {
            while (!tok.hasMoreElements())
                tok = new StringTokenizer(cur = buff.readLine());

            return tok.nextToken();
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class D129D2 {

    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader(System.in);
        int n = in.nextInt();
        HashMap<Integer, Integer> m = new HashMap<Integer, Integer>(1500000);
        int top = 0;
        int[] back = new int[2 * n];
        int[] front = new int[2 * n];
        int[] both = new int[2 * n];
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (!m.containsKey(a))
                m.put(a, top++);
            if (!m.containsKey(b))
                m.put(b, top++);

            int x = m.get(a);
            int y = m.get(b);
            front[x]++;
            back[y]++;
            if (x == y)
                both[x]++;
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            back[i] -= both[i];
            if (n - 2 * front[i] <= 2 * back[i]) {
                if (n - 2 * front[i] > 0)
                    min = Math.min(min, (n - 2 * front[i]) / 2
                            + (n - 2 * front[i]) % 2);
                else
                    min = 0;
            }
        }
        if (min == Integer.MAX_VALUE)
            System.out.println(-1);
        else
            System.out.println(Math.max(min, 0));
    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class D129D2 {

    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader(System.in);
        int n = in.nextInt();
        HashMap<Integer, Integer> m = new HashMap<Integer, Integer>(1000000);
        int top = 0;
        int[] back = new int[2 * n];
        int[] front = new int[2 * n];
        int[] both = new int[2 * n];
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (!m.containsKey(a))
                m.put(a, top++);
            if (!m.containsKey(b))
                m.put(b, top++);

            int x = m.get(a);
            int y = m.get(b);
            front[x]++;
            back[y]++;
            if (x == y)
                both[x]++;
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            back[i] -= both[i];
            if (n - 2 * front[i] <= 2 * back[i]) {
                if (n - 2 * front[i] > 0)
                    min = Math.min(min, (n - 2 * front[i]) / 2
                            + (n - 2 * front[i]) % 2);
                else
                    min = 0;
            }
        }
        if (min == Integer.MAX_VALUE)
            System.out.println(-1);
        else
            System.out.println(Math.max(min, 0));
    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class D129D2 {

    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader(System.in);
        int n = in.nextInt();
        TreeMap<Integer, Integer> m = new TreeMap<Integer, Integer>();
        int top = 0;
        int[] back = new int[2 * n];
        int[] front = new int[2 * n];
        int[] both = new int[2 * n];
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (!m.containsKey(a))
                m.put(a, top++);
            if (!m.containsKey(b))
                m.put(b, top++);

            int x = m.get(a);
            int y = m.get(b);
            front[x]++;
            back[y]++;
            if (x == y)
                both[x]++;
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            back[i] -= both[i];
            if (n - 2 * front[i] <= 2 * back[i]) {
                if (n - 2 * front[i] > 0)
                    min = Math.min(min, (n - 2 * front[i]) / 2
                            + (n - 2 * front[i]) % 2);
                else
                    min = 0;
            }
        }
        if (min == Integer.MAX_VALUE)
            System.out.println(-1);
        else
            System.out.println(Math.max(min, 0));
    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class D129D2 {

    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader(System.in);
        int n = in.nextInt();
        HashMap<Integer, Integer> m = new HashMap<Integer, Integer>();
        int top = 0;
        int[] back = new int[2 * n];
        int[] front = new int[2 * n];
        int[] both = new int[2 * n];
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (!m.containsKey(a))
                m.put(a, top++);
            if (!m.containsKey(b))
                m.put(b, top++);

            int x = m.get(a);
            int y = m.get(b);
            front[x]++;
            back[y]++;
            if (x == y)
                both[x]++;
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            back[i] -= both[i];
            if (n - 2 * front[i] <= 2 * back[i]) {
                if (n - 2 * front[i] > 0)
                    min = Math.min(min, (n - 2 * front[i]) / 2
                            + (n - 2 * front[i]) % 2);
                else
                    min = 0;
            }
        }
        if (min == Integer.MAX_VALUE)
            System.out.println(-1);
        else
            System.out.println(Math.max(min, 0));
    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author andrey
 */
public class CC {
 public static void main(String args[])throws Exception{
     BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

     int n = Integer.parseInt(in.readLine());
     int x[] = new int[n];
     int y[] = new int[n];
     int a[] = new int[n+n];
     Arrays.fill(a,-1);
     for (int i = 0; i < n; i++) {
         StringTokenizer st =new StringTokenizer(in.readLine());
         x[i] = Integer.parseInt(st.nextToken());
         y[i] = Integer.parseInt(st.nextToken());
         a[i] = x[i];
         a[n+i]= (x[i]!=y[i]?y[i]:-1);
     }

     Arrays.sort(a);
     ArrayList<Integer> posColors = new ArrayList<Integer>();
     int i=0;
     while(a[i]==-1) i++;
     for(;i<a.length;){
         int q = 0;
         int c = a[i];
         while(i<a.length&&a[i]==c){
             q++;i++;
         }
         if(q>=(n/2+n%2)){
             posColors.add(c);
         }
     }
     if(posColors.size()==0){
         System.out.println(-1);
     }else{

         int min = Integer.MAX_VALUE;

         int need = n/2+n%2;
         for(int col:posColors){
             int cur = 0;
             for(int j=0;j<n;j++)
                 if(x[j]==col) cur++;
             if(cur>=need) {
                 min=0;
                 break;
             }

             int turn = 0;
             for(int j=0;j<n;j++)
                 if(y[j]==col&&x[j]!=col){
                     turn++;
                     if(cur+turn>=need) break;
                 }
             if(turn<min) min = turn;

         }

         System.out.println(min);
     }
 }

}


import java.util.*;

/**
 *
 *

 * Unsolved
 *

 *

 * Created on Jul 11, 2012, 12:13:12 PM
 *

 * @Author Andy Y.F. Huang
 */
public class p205DLittleElephantandCards {
  private void solve(int test_number) {
    int len = in.nextInt();
    int top[] = new int[len];
    int bot[] = new int[len];
    Map<Integer, Integer> cnt1 = new TreeMap<Integer, Integer>();
    Map<Integer, Integer> cnt2 = new TreeMap<Integer, Integer>();
    Set<Integer> vals = new TreeSet<Integer>();
    for (int i = 0; i < len; i++) {
      top[i] = in.nextInt();
      bot[i] = in.nextInt();
      vals.add(top[i]);
      vals.add(bot[i]);
      Integer cnt = cnt1.get(top[i]);
      if (cnt == null)
        cnt1.put(top[i], 1);
      else
        cnt1.put(top[i], cnt + 1);
      if (top[i] == bot[i]) {
        bot[i] = -1;
        continue;
      }
      cnt = cnt2.get(bot[i]);
      if (cnt == null)
        cnt2.put(bot[i], 1);
      else
        cnt2.put(bot[i], cnt + 1);
    }
    int half = len >> 1;
    if (len % 2 == 1)
      half++;
    int ans = Integer.MAX_VALUE;
    boolean poss = false;
    for (Integer num : vals) {
      Integer a = cnt1.get(num);
      if (a == null)
        a = 0;
      Integer b = cnt2.get(num);
      if (b == null)
        b = 0;
      if (a + b >= half) {
        poss = true;
        ans = Math.min(ans, Math.max(0, half - a));
      }
    }
    if (!poss)
      out.appendln(-1);
    else
      out.appendln(ans);
  }

  private Input in;
  private Output out;

  void solve() {
    in = new Input("");
    out = new Output("");
    solve(1);
    out.close();
  }

  public static void main(String[] args) {
    p205DLittleElephantandCards solver = new p205DLittleElephantandCards();
    solver.solve();
  }

  static void pln(Object... obj) {
    pf(obj);
    System.out.println();
  }

  static void pf(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        System.out.print(' ');
      System.out.print(obj[i]);

    }
  }
}

final class Input {
  private java.io.BufferedReader reader;
  private java.util.StringTokenizer tokenizer;

  Input(String filename) {
    if (!filename.isEmpty()) {
      try {
        reader = new java.io.BufferedReader(new java.io.FileReader(filename));
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    }
    else
      reader = new java.io.BufferedReader(new java.io.InputStreamReader(
          System.in));
    tokenizer = new java.util.StringTokenizer("");
  }

  String next() {
    while (!tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      }
      catch (java.io.IOException e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  String nextLine() {
    try {
      return reader.readLine();
    }
    catch (java.io.IOException e) {
      throw new RuntimeException(e);
    }
  }

  long nextLong() {
    return Long.parseLong(next());
  }

  int nextInt() {
    return Integer.parseInt(next());
  }

  double nextDouble() {
    return Double.parseDouble(next());
  }

}

final class Output {
  private java.io.PrintWriter buffer;

  Output(String filename) {
    if (!filename.isEmpty())
      try {
        buffer = new java.io.PrintWriter(filename);
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException();
      }
    else
      buffer = new java.io.PrintWriter(System.out);
  }

  void flush() {
    buffer.flush();
  }

  void close() {
    buffer.close();
  }

  void append(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        buffer.write(' ');
      buffer.print(obj[i]);
    }
  }

  void appendln(Object... obj) {
    append(obj);
    buffer.write('\n');
  }

}


import java.util.*;

/**
 *
 *

 * Unsolved
 *

 *

 * Created on Jul 11, 2012, 12:13:12 PM
 *

 * @Author Andy Y.F. Huang
 */
public class p205D {
  private void solve(int test_number) {
    int len = in.nextInt();
    int top[] = new int[len];
    int bot[] = new int[len];
    Map<Integer, Integer> cnt1 = new HashMap<Integer, Integer>(len);
    Map<Integer, Integer> cnt2 = new HashMap<Integer, Integer>(len);
    for (int i = 0; i < len; i++) {
      top[i] = in.nextInt();
      bot[i] = in.nextInt();
      Integer cnt = cnt1.get(top[i]);
      if (cnt == null)
        cnt1.put(top[i], 1);
      else
        cnt1.put(top[i], cnt + 1);
      if (top[i] == bot[i]) {
        bot[i] = -1;
        continue;
      }
      cnt = cnt2.get(bot[i]);
      if (cnt == null)
        cnt2.put(bot[i], 1);
      else
        cnt2.put(bot[i], cnt + 1);
    }
    int half = len >> 1;
    if (len % 2 == 1)
      half++;
    int ans = Integer.MAX_VALUE;
    boolean poss = false;
    for (Map.Entry<Integer, Integer> num : cnt1.entrySet()) {
      Integer second = cnt2.get(num.getKey());
      if (second == null)
        continue;
      if (num.getValue() + second >= half) {
        ans = Math.min(ans, half - num.getValue());
        poss = true;
      }
    }
    if (!poss)
      out.appendln(-1);
    else
      out.appendln(ans);
  }

  private Input in;
  private Output out;

  void solve() {
    in = new Input("");
    out = new Output("");
    solve(1);
    out.close();
  }

  public static void main(String[] args) {
    p205D solver = new p205D();
    solver.solve();
  }

  static void pln(Object... obj) {
    pf(obj);
    System.out.println();
  }

  static void pf(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        System.out.print(' ');
      System.out.print(obj[i]);

    }
  }
}

final class Input {
  private java.io.BufferedReader reader;
  private java.util.StringTokenizer tokenizer;

  Input(String filename) {
    if (!filename.isEmpty()) {
      try {
        reader = new java.io.BufferedReader(new java.io.FileReader(filename));
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    }
    else
      reader = new java.io.BufferedReader(new java.io.InputStreamReader(
          System.in));
    tokenizer = new java.util.StringTokenizer("");
  }

  String next() {
    while (!tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      }
      catch (java.io.IOException e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  String nextLine() {
    try {
      return reader.readLine();
    }
    catch (java.io.IOException e) {
      throw new RuntimeException(e);
    }
  }

  long nextLong() {
    return Long.parseLong(next());
  }

  int nextInt() {
    return Integer.parseInt(next());
  }

  double nextDouble() {
    return Double.parseDouble(next());
  }

}

final class Output {
  private java.io.PrintWriter buffer;

  Output(String filename) {
    if (!filename.isEmpty())
      try {
        buffer = new java.io.PrintWriter(filename);
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException();
      }
    else
      buffer = new java.io.PrintWriter(System.out);
  }

  void flush() {
    buffer.flush();
  }

  void close() {
    buffer.close();
  }

  void append(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        buffer.write(' ');
      buffer.print(obj[i]);
    }
  }

  void appendln(Object... obj) {
    append(obj);
    buffer.write('\n');
  }

}


import java.util.*;

/**
 *
 *

 * Unsolved
 *

 *

 * Created on Jul 11, 2012, 12:13:12 PM
 *

 * @Author Andy Y.F. Huang
 */
public class p205D {
  private void solve(int test_number) {
    int len = in.nextInt();
    int top[] = new int[len];
    int bot[] = new int[len];
    Map<Integer, Integer> cnt1 = new HashMap<Integer, Integer>(len);
    Map<Integer, Integer> cnt2 = new HashMap<Integer, Integer>(len);
    for (int i = 0; i < len; i++) {
      top[i] = in.nextInt();
      bot[i] = in.nextInt();
      Integer cnt = cnt1.get(top[i]);
      if (cnt == null)
        cnt1.put(top[i], 1);
      else
        cnt1.put(top[i], cnt + 1);
      if (top[i] == bot[i]) {
        bot[i] = -1;
        continue;
      }
      cnt = cnt2.get(bot[i]);
      if (cnt == null)
        cnt2.put(bot[i], 1);
      else
        cnt2.put(bot[i], cnt + 1);
    }
    int half = len >> 1;
    if (len % 2 == 1)
      half++;
    for (Map.Entry<Integer, Integer> num : cnt1.entrySet()) {
      Integer second = cnt2.get(num.getKey());
      if (second == null)
        continue;
      if (num.getValue() + second >= half) {
        out.appendln(half - num.getValue());
        return;
      }
    }
    out.appendln(-1);
  }

  private Input in;
  private Output out;

  void solve() {
    in = new Input("");
    out = new Output("");
    solve(1);
    out.close();
  }

  public static void main(String[] args) {
    p205D solver = new p205D();
    solver.solve();
  }

  static void pln(Object... obj) {
    pf(obj);
    System.out.println();
  }

  static void pf(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        System.out.print(' ');
      System.out.print(obj[i]);

    }
  }
}

final class Input {
  private java.io.BufferedReader reader;
  private java.util.StringTokenizer tokenizer;

  Input(String filename) {
    if (!filename.isEmpty()) {
      try {
        reader = new java.io.BufferedReader(new java.io.FileReader(filename));
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    }
    else
      reader = new java.io.BufferedReader(new java.io.InputStreamReader(
          System.in));
    tokenizer = new java.util.StringTokenizer("");
  }

  String next() {
    while (!tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      }
      catch (java.io.IOException e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  String nextLine() {
    try {
      return reader.readLine();
    }
    catch (java.io.IOException e) {
      throw new RuntimeException(e);
    }
  }

  long nextLong() {
    return Long.parseLong(next());
  }

  int nextInt() {
    return Integer.parseInt(next());
  }

  double nextDouble() {
    return Double.parseDouble(next());
  }

}

final class Output {
  private java.io.PrintWriter buffer;

  Output(String filename) {
    if (!filename.isEmpty())
      try {
        buffer = new java.io.PrintWriter(filename);
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException();
      }
    else
      buffer = new java.io.PrintWriter(System.out);
  }

  void flush() {
    buffer.flush();
  }

  void close() {
    buffer.close();
  }

  void append(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        buffer.write(' ');
      buffer.print(obj[i]);
    }
  }

  void appendln(Object... obj) {
    append(obj);
    buffer.write('\n');
  }

}


import java.util.*;

/**
 *
 *

 * Unsolved
 *

 *

 * Created on Jul 11, 2012, 12:13:12 PM
 *

 * @Author Andy Y.F. Huang
 */
public class p205DLittleElephantandCards {
  private void solve(int test_number) {
    int len = in.nextInt();
    int top[] = new int[len];
    int bot[] = new int[len];
    Map<Integer, Integer> cnt1 = new HashMap<Integer, Integer>(len * 3);
    Map<Integer, Integer> cnt2 = new HashMap<Integer, Integer>(len * 3);
    Set<Integer> vals = new HashSet<Integer>(len * 3);
    for (int i = 0; i < len; i++) {
      top[i] = in.nextInt();
      bot[i] = in.nextInt();
      vals.add(top[i]);
      vals.add(bot[i]);
      Integer cnt = cnt1.get(top[i]);
      if (cnt == null)
        cnt1.put(top[i], 1);
      else
        cnt1.put(top[i], cnt + 1);
      if (top[i] == bot[i]) {
        bot[i] = -1;
        continue;
      }
      cnt = cnt2.get(bot[i]);
      if (cnt == null)
        cnt2.put(bot[i], 1);
      else
        cnt2.put(bot[i], cnt + 1);
    }
    int half = len >> 1;
    if (len % 2 == 1)
      half++;
    int ans = Integer.MAX_VALUE;
    boolean poss = false;
    for (Integer num : vals) {
      Integer a = cnt1.get(num);
      if (a == null)
        a = 0;
      Integer b = cnt2.get(num);
      if (b == null)
        b = 0;
      if (a + b >= half) {
        poss = true;
        ans = Math.min(ans, Math.max(0, half - a));
      }
    }
    if (!poss)
      out.appendln(-1);
    else
      out.appendln(ans);
  }

  private Input in;
  private Output out;

  void solve() {
    in = new Input("");
    out = new Output("");
    solve(1);
    out.close();
  }

  public static void main(String[] args) {
    p205DLittleElephantandCards solver = new p205DLittleElephantandCards();
    solver.solve();
  }

  static void pln(Object... obj) {
    pf(obj);
    System.out.println();
  }

  static void pf(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        System.out.print(' ');
      System.out.print(obj[i]);

    }
  }
}

final class Input {
  private java.io.BufferedReader reader;
  private java.util.StringTokenizer tokenizer;

  Input(String filename) {
    if (!filename.isEmpty()) {
      try {
        reader = new java.io.BufferedReader(new java.io.FileReader(filename));
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    }
    else
      reader = new java.io.BufferedReader(new java.io.InputStreamReader(
          System.in));
    tokenizer = new java.util.StringTokenizer("");
  }

  String next() {
    while (!tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      }
      catch (java.io.IOException e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  String nextLine() {
    try {
      return reader.readLine();
    }
    catch (java.io.IOException e) {
      throw new RuntimeException(e);
    }
  }

  long nextLong() {
    return Long.parseLong(next());
  }

  int nextInt() {
    return Integer.parseInt(next());
  }

  double nextDouble() {
    return Double.parseDouble(next());
  }

}

final class Output {
  private java.io.PrintWriter buffer;

  Output(String filename) {
    if (!filename.isEmpty())
      try {
        buffer = new java.io.PrintWriter(filename);
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException();
      }
    else
      buffer = new java.io.PrintWriter(System.out);
  }

  void flush() {
    buffer.flush();
  }

  void close() {
    buffer.close();
  }

  void append(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        buffer.write(' ');
      buffer.print(obj[i]);
    }
  }

  void appendln(Object... obj) {
    append(obj);
    buffer.write('\n');
  }

}


import java.util.*;

/**
 *
 *

 * Unsolved
 *

 *

 * Created on Jul 11, 2012, 12:13:12 PM
 *

 * @Author Andy Y.F. Huang
 */
public class p205DLittleElephantandCards {
  private void solve(int test_number) {
    int len = in.nextInt();
    int top[] = new int[len];
    int bot[] = new int[len];
    Map<Integer, Integer> cnt1 = new HashMap<Integer, Integer>(len * 3);
    Map<Integer, Integer> cnt2 = new HashMap<Integer, Integer>(len * 3);
    Set<Integer> vals = new TreeSet<Integer>();
    for (int i = 0; i < len; i++) {
      top[i] = in.nextInt();
      bot[i] = in.nextInt();
      vals.add(top[i]);
      vals.add(bot[i]);
      Integer cnt = cnt1.get(top[i]);
      if (cnt == null)
        cnt1.put(top[i], 1);
      else
        cnt1.put(top[i], cnt + 1);
      if (top[i] == bot[i]) {
        bot[i] = -1;
        continue;
      }
      cnt = cnt2.get(bot[i]);
      if (cnt == null)
        cnt2.put(bot[i], 1);
      else
        cnt2.put(bot[i], cnt + 1);
    }
    int half = len >> 1;
    if (len % 2 == 1)
      half++;
    int ans = Integer.MAX_VALUE;
    boolean poss = false;
    for (Integer num : vals) {
      Integer a = cnt1.get(num);
      if (a == null)
        a = 0;
      Integer b = cnt2.get(num);
      if (b == null)
        b = 0;
      if (a + b >= half) {
        poss = true;
        ans = Math.min(ans, Math.max(0, half - a));
      }
    }
    if (!poss)
      out.appendln(-1);
    else
      out.appendln(ans);
  }

  private Input in;
  private Output out;

  void solve() {
    in = new Input("");
    out = new Output("");
    solve(1);
    out.close();
  }

  public static void main(String[] args) {
    p205DLittleElephantandCards solver = new p205DLittleElephantandCards();
    solver.solve();
  }

  static void pln(Object... obj) {
    pf(obj);
    System.out.println();
  }

  static void pf(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        System.out.print(' ');
      System.out.print(obj[i]);

    }
  }
}

final class Input {
  private java.io.BufferedReader reader;
  private java.util.StringTokenizer tokenizer;

  Input(String filename) {
    if (!filename.isEmpty()) {
      try {
        reader = new java.io.BufferedReader(new java.io.FileReader(filename));
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    }
    else
      reader = new java.io.BufferedReader(new java.io.InputStreamReader(
          System.in));
    tokenizer = new java.util.StringTokenizer("");
  }

  String next() {
    while (!tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      }
      catch (java.io.IOException e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  String nextLine() {
    try {
      return reader.readLine();
    }
    catch (java.io.IOException e) {
      throw new RuntimeException(e);
    }
  }

  long nextLong() {
    return Long.parseLong(next());
  }

  int nextInt() {
    return Integer.parseInt(next());
  }

  double nextDouble() {
    return Double.parseDouble(next());
  }

}

final class Output {
  private java.io.PrintWriter buffer;

  Output(String filename) {
    if (!filename.isEmpty())
      try {
        buffer = new java.io.PrintWriter(filename);
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException();
      }
    else
      buffer = new java.io.PrintWriter(System.out);
  }

  void flush() {
    buffer.flush();
  }

  void close() {
    buffer.close();
  }

  void append(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        buffer.write(' ');
      buffer.print(obj[i]);
    }
  }

  void appendln(Object... obj) {
    append(obj);
    buffer.write('\n');
  }

}


import java.util.*;

/**
 *
 *

 * Unsolved
 *

 *

 * Created on Jul 11, 2012, 12:13:12 PM
 *

 * @Author Andy Y.F. Huang
 */
public class p205D {
  private void solve(int test_number) {
    int len = in.nextInt();
    int top[] = new int[len];
    int bot[] = new int[len];
    Map<Integer, Integer> cnt1 = new HashMap<Integer, Integer>(len);
    Map<Integer, Integer> cnt2 = new HashMap<Integer, Integer>(len);
    for (int i = 0; i < len; i++) {
      top[i] = in.nextInt();
      bot[i] = in.nextInt();
      Integer cnt = cnt1.get(top[i]);
      if (cnt == null)
        cnt1.put(top[i], 1);
      else
        cnt1.put(top[i], cnt + 1);
      if (top[i] == bot[i]) {
        bot[i] = -1;
        continue;
      }
      cnt = cnt2.get(bot[i]);
      if (cnt == null)
        cnt2.put(bot[i], 1);
      else
        cnt2.put(bot[i], cnt + 1);
    }
    int half = len >> 1;
    if (len % 2 == 1)
      half++;
    int ans = Integer.MAX_VALUE;
    boolean poss = false;
    for (Map.Entry<Integer, Integer> num : cnt1.entrySet()) {
      Integer second = cnt2.get(num.getKey());
      if (second == null)
        second = 0;
      if (num.getValue() + second >= half) {
        ans = Math.min(ans, half - num.getValue());
        poss = true;
      }
    }
    if (!poss)
      out.appendln(-1);
    else
      out.appendln(ans);
  }

  private Input in;
  private Output out;

  void solve() {
    in = new Input("");
    out = new Output("");
    solve(1);
    out.close();
  }

  public static void main(String[] args) {
    p205D solver = new p205D();
    solver.solve();
  }

  static void pln(Object... obj) {
    pf(obj);
    System.out.println();
  }

  static void pf(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        System.out.print(' ');
      System.out.print(obj[i]);

    }
  }
}

final class Input {
  private java.io.BufferedReader reader;
  private java.util.StringTokenizer tokenizer;

  Input(String filename) {
    if (!filename.isEmpty()) {
      try {
        reader = new java.io.BufferedReader(new java.io.FileReader(filename));
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    }
    else
      reader = new java.io.BufferedReader(new java.io.InputStreamReader(
          System.in));
    tokenizer = new java.util.StringTokenizer("");
  }

  String next() {
    while (!tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      }
      catch (java.io.IOException e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  String nextLine() {
    try {
      return reader.readLine();
    }
    catch (java.io.IOException e) {
      throw new RuntimeException(e);
    }
  }

  long nextLong() {
    return Long.parseLong(next());
  }

  int nextInt() {
    return Integer.parseInt(next());
  }

  double nextDouble() {
    return Double.parseDouble(next());
  }

}

final class Output {
  private java.io.PrintWriter buffer;

  Output(String filename) {
    if (!filename.isEmpty())
      try {
        buffer = new java.io.PrintWriter(filename);
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException();
      }
    else
      buffer = new java.io.PrintWriter(System.out);
  }

  void flush() {
    buffer.flush();
  }

  void close() {
    buffer.close();
  }

  void append(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        buffer.write(' ');
      buffer.print(obj[i]);
    }
  }

  void appendln(Object... obj) {
    append(obj);
    buffer.write('\n');
  }

}


import java.util.*;

/**
 *
 *

 * Unsolved
 *

 *

 * Created on Jul 11, 2012, 12:13:12 PM
 *

 * @Author Andy Y.F. Huang
 */
public class p205D {
  private void solve(int test_number) {
    int len = in.nextInt();
    int top[] = new int[len];
    int bot[] = new int[len];
    Map<Integer, Integer> cnt1 = new HashMap<Integer, Integer>(len);
    Map<Integer, Integer> cnt2 = new HashMap<Integer, Integer>(len);
    for (int i = 0; i < len; i++) {
      top[i] = in.nextInt();
      bot[i] = in.nextInt();
      Integer cnt = cnt1.get(top[i]);
      if (cnt == null)
        cnt1.put(top[i], 1);
      else
        cnt1.put(top[i], cnt + 1);
      if (top[i] == bot[i]) {
        bot[i] = -1;
        continue;
      }
      cnt = cnt2.get(bot[i]);
      if (cnt == null)
        cnt2.put(bot[i], 1);
      else
        cnt2.put(bot[i], cnt + 1);
    }
    int half = len >> 1;
    if (len % 2 == 1)
      half++;
    int ans = Integer.MAX_VALUE;
    boolean poss = false;
    for (Map.Entry<Integer, Integer> num : cnt1.entrySet()) {
      Integer second = cnt2.get(num.getKey());
      if (second == null)
        second = 0;
      if (num.getValue() + second >= half) {
        ans = Math.min(ans, Math.max(0, half - num.getValue()));
        poss = true;
      }
    }
    if (!poss)
      out.appendln(-1);
    else
      out.appendln(ans);
  }

  private Input in;
  private Output out;

  void solve() {
    in = new Input("");
    out = new Output("");
    solve(1);
    out.close();
  }

  public static void main(String[] args) {
    p205D solver = new p205D();
    solver.solve();
  }

  static void pln(Object... obj) {
    pf(obj);
    System.out.println();
  }

  static void pf(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        System.out.print(' ');
      System.out.print(obj[i]);

    }
  }
}

final class Input {
  private java.io.BufferedReader reader;
  private java.util.StringTokenizer tokenizer;

  Input(String filename) {
    if (!filename.isEmpty()) {
      try {
        reader = new java.io.BufferedReader(new java.io.FileReader(filename));
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    }
    else
      reader = new java.io.BufferedReader(new java.io.InputStreamReader(
          System.in));
    tokenizer = new java.util.StringTokenizer("");
  }

  String next() {
    while (!tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      }
      catch (java.io.IOException e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  String nextLine() {
    try {
      return reader.readLine();
    }
    catch (java.io.IOException e) {
      throw new RuntimeException(e);
    }
  }

  long nextLong() {
    return Long.parseLong(next());
  }

  int nextInt() {
    return Integer.parseInt(next());
  }

  double nextDouble() {
    return Double.parseDouble(next());
  }

}

final class Output {
  private java.io.PrintWriter buffer;

  Output(String filename) {
    if (!filename.isEmpty())
      try {
        buffer = new java.io.PrintWriter(filename);
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException();
      }
    else
      buffer = new java.io.PrintWriter(System.out);
  }

  void flush() {
    buffer.flush();
  }

  void close() {
    buffer.close();
  }

  void append(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        buffer.write(' ');
      buffer.print(obj[i]);
    }
  }

  void appendln(Object... obj) {
    append(obj);
    buffer.write('\n');
  }

}


import java.util.*;

/**
 *
 *

 * Unsolved
 *

 *

 * Created on Jul 11, 2012, 12:13:12 PM
 *

 * @Author Andy Y.F. Huang
 */
public class p205DLittleElephantandCards {
  private void solve(int test_number) {
    int len = in.nextInt();
    int top[] = new int[len];
    int bot[] = new int[len];
    Map<Integer, Integer> cnt1 = new HashMap<Integer, Integer>(len);
    Map<Integer, Integer> cnt2 = new HashMap<Integer, Integer>(len);
    Set<Integer> vals = new HashSet<Integer>(len);
    for (int i = 0; i < len; i++) {
      top[i] = in.nextInt();
      bot[i] = in.nextInt();
      vals.add(top[i]);
      vals.add(bot[i]);
      Integer cnt = cnt1.get(top[i]);
      if (cnt == null)
        cnt1.put(top[i], 1);
      else
        cnt1.put(top[i], cnt + 1);
      if (top[i] == bot[i]) {
        bot[i] = -1;
        continue;
      }
      cnt = cnt2.get(bot[i]);
      if (cnt == null)
        cnt2.put(bot[i], 1);
      else
        cnt2.put(bot[i], cnt + 1);
    }
    int half = len >> 1;
    if (len % 2 == 1)
      half++;
    int ans = Integer.MAX_VALUE;
    boolean poss = false;
    for (Integer num : vals) {
      Integer a = cnt1.get(num);
      if (a == null)
        a = 0;
      Integer b = cnt2.get(num);
      if (b == null)
        b = 0;
      if (a + b >= half) {
        poss = true;
        ans = Math.min(ans, Math.max(0, half - a));
      }
    }
    if (!poss)
      out.appendln(-1);
    else
      out.appendln(ans);
  }

  private Input in;
  private Output out;

  void solve() {
    in = new Input("");
    out = new Output("");
    solve(1);
    out.close();
  }

  public static void main(String[] args) {
    p205DLittleElephantandCards solver = new p205DLittleElephantandCards();
    solver.solve();
  }

  static void pln(Object... obj) {
    pf(obj);
    System.out.println();
  }

  static void pf(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        System.out.print(' ');
      System.out.print(obj[i]);

    }
  }
}

final class Input {
  private java.io.BufferedReader reader;
  private java.util.StringTokenizer tokenizer;

  Input(String filename) {
    if (!filename.isEmpty()) {
      try {
        reader = new java.io.BufferedReader(new java.io.FileReader(filename));
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    }
    else
      reader = new java.io.BufferedReader(new java.io.InputStreamReader(
          System.in));
    tokenizer = new java.util.StringTokenizer("");
  }

  String next() {
    while (!tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      }
      catch (java.io.IOException e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  String nextLine() {
    try {
      return reader.readLine();
    }
    catch (java.io.IOException e) {
      throw new RuntimeException(e);
    }
  }

  long nextLong() {
    return Long.parseLong(next());
  }

  int nextInt() {
    return Integer.parseInt(next());
  }

  double nextDouble() {
    return Double.parseDouble(next());
  }

}

final class Output {
  private java.io.PrintWriter buffer;

  Output(String filename) {
    if (!filename.isEmpty())
      try {
        buffer = new java.io.PrintWriter(filename);
      }
      catch (java.io.FileNotFoundException e) {
        throw new RuntimeException();
      }
    else
      buffer = new java.io.PrintWriter(System.out);
  }

  void flush() {
    buffer.flush();
  }

  void close() {
    buffer.close();
  }

  void append(Object... obj) {
    for (int i = 0; i < obj.length; i++) {
      if (i != 0)
        buffer.write(' ');
      buffer.print(obj[i]);
    }
  }

  void appendln(Object... obj) {
    append(obj);
    buffer.write('\n');
  }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

public class Cards2 {

    BufferedReader in;
    StringTokenizer st;
    PrintWriter out;

    public static void main(String[] args) {
        Cards2 t = new Cards2();
        t.init();
    }

    void run() throws Exception {
        int n = Int();
        int hn = n % 2 == 0 ? n / 2 : n / 2 + 1;
        Map<Integer, Integer> topColors = new HashMap<Integer, Integer>();
        Map<Integer, Integer> bottomColors = new HashMap<Integer, Integer>();
        Map<Integer, Integer> duplicColors = new HashMap<Integer, Integer>();
        Set<Integer> colors = new HashSet<Integer>();

        for (int i = 0; i < n; i++) {
            int a = Int();
            if (topColors.containsKey(a)) {
                topColors.put(a, topColors.get(a) + 1);
            } else {
                topColors.put(a, 1);
            }
            int b = Int();
            if (bottomColors.containsKey(b)) {
                bottomColors.put(b, bottomColors.get(b) + 1);
            } else {
                bottomColors.put(b, 1);
            }
            if (a == b) {
                if (duplicColors.containsKey(a)) {
                    duplicColors.put(a, duplicColors.get(a) + 1);
                } else {
                    duplicColors.put(a, 1);
                }
            }
            colors.add(a);
            colors.add(b);
        }
        int leastMoves = Integer.MAX_VALUE;

        for (Integer col : colors) {
            Integer ai = topColors.get(col);
            Integer bi = bottomColors.get(col);
            Integer ci = duplicColors.get(col);
            int a = ai == null ? 0 : ai;
            int b = bi == null ? 0 : bi;
            int c = ci == null ? 0 : ci;
            if (a + b - c >= hn) {
                int moves = Math.max(0, hn - a);
                if (moves < leastMoves) {
                    leastMoves = moves;
                }
                if (leastMoves == 0) {
                    break;
                }
            }
        }

        PrintLn(leastMoves == Integer.MAX_VALUE ? -1 : leastMoves);
    }

    void init() {
        try {
            Locale.setDefault(Locale.US);
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
            run();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    int Int() throws Exception {
        return Integer.parseInt(next());
    }

    long Long() throws Exception {
        return Long.parseLong(next());
    }

    double Double() throws Exception {
        return Double.parseDouble(next());
    }

    void PrintLn(Object line) {
        out.println(line);
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Cards2 {

    BufferedReader in;
    StringTokenizer st;
    PrintWriter out;

    public static void main(String[] args) {
        Cards2 t = new Cards2();
        t.init();
    }

    void run() throws Exception {
        int n = Int();
        int hn = n % 2 == 0 ? n / 2 : n / 2 + 1;
        TreeIntCounter<Integer> topColors = new TreeIntCounter<Integer>();
        TreeIntCounter<Integer> bottomColors = new TreeIntCounter<Integer>();
        TreeIntCounter<Integer> duplicColors = new TreeIntCounter<Integer>();
        Set<Integer> colors = new TreeSet<Integer>();

        for (int i = 0; i < n; i++) {
            int a = Int();
            topColors.increment(a);
            int b = Int();
            bottomColors.increment(b);
            if (a == b) {
                duplicColors.increment(a);
            }
            colors.add(a);
            colors.add(b);
        }
        int leastMoves = Integer.MAX_VALUE;

        for (Integer col : colors) {
            int a = (int) topColors.count(col);
            int b = (int) bottomColors.count(col);
            int c = (int) duplicColors.count(col);
            if (a + b - c >= hn) {
                int moves = Math.max(0, hn - a);
                if (moves < leastMoves) {
                    leastMoves = moves;
                }
                if (leastMoves == 0) {
                    break;
                }
            }
        }

        PrintLn(leastMoves == Integer.MAX_VALUE ? -1 : leastMoves);
    }

    void init() {
        try {
            Locale.setDefault(Locale.US);
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
            run();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    int Int() throws Exception {
        return Integer.parseInt(next());
    }

    long Long() throws Exception {
        return Long.parseLong(next());
    }

    double Double() throws Exception {
        return Double.parseDouble(next());
    }

    void PrintLn(Object line) {
        out.println(line);
    }

    static class TreeIntCounter<K> {
        private final TreeMap<K, int[]> map = new TreeMap<K, int[]>();

        public void increment(K element) {
            int[] el = map.get(element);
            if (el == null) {
                map.put(element, new int[]{1});
            } else {
                el[0]++;
            }
        }

        public int count(K element) {
            int[] el = map.get(element);
            return el == null ? 0 : map.get(element)[0];
        }

        public Set<K> getKeySet() {
            return map.keySet();
        }

    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Cards2 {

    BufferedReader in;
    StringTokenizer st;
    PrintWriter out;

    public static void main(String[] args) {
        Cards2 t = new Cards2();
        t.init();
    }

    void run() throws Exception {
        int n = Int();
        int hn = n % 2 == 0 ? n / 2 : n / 2 + 1;
        HashCounter<Integer> topColors = new HashCounter<Integer>();
        HashCounter<Integer> bottomColors = new HashCounter<Integer>();
        HashCounter<Integer> duplicColors = new HashCounter<Integer>();
        Set<Integer> colors = new TreeSet<Integer>();

        for (int i = 0; i < n; i++) {
            int a = Int();
            topColors.increment(a);
            int b = Int();
            bottomColors.increment(b);
            if (a == b) {
                duplicColors.increment(a);
            }
            colors.add(a);
            colors.add(b);
        }
        int leastMoves = Integer.MAX_VALUE;

        for (Integer col : colors) {
            int a = (int) topColors.count(col);
            int b = (int) bottomColors.count(col);
            int c = (int) duplicColors.count(col);
            if (a + b - c >= hn) {
                int moves = Math.max(0, hn - a);
                if (moves < leastMoves) {
                    leastMoves = moves;
                }
                if (leastMoves == 0) {
                    break;
                }
            }
        }

        PrintLn(leastMoves == Integer.MAX_VALUE ? -1 : leastMoves);
    }

    void init() {
        try {
            Locale.setDefault(Locale.US);
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
            run();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    int Int() throws Exception {
        return Integer.parseInt(next());
    }

    long Long() throws Exception {
        return Long.parseLong(next());
    }

    double Double() throws Exception {
        return Double.parseDouble(next());
    }

    void PrintLn(Object line) {
        out.println(line);
    }

    static class HashCounter<K> {
        private final TreeMap<K, long[]> map = new TreeMap<K, long[]>();

        public void increment(K element) {
            long[] el = map.get(element);
            if (el == null) {
                map.put(element, new long[]{1});
            } else {
                el[0]++;
            }
        }

        public long count(K element) {
            long[] el = map.get(element);
            return el == null ? 0 : map.get(element)[0];
        }

        public Set<K> getKeySet() {
            return map.keySet();
        }

    }

}


import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Cards {

    static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = Int();
        int hn = n % 2 == 0 ? n / 2 : n / 2 + 1;
        Map<Integer, Integer> topColors = new HashMap<Integer, Integer>();
        Map<Integer, Integer> bottomColors = new HashMap<Integer, Integer>();

        for (int i = 0; i < n; i++) {
            int a = Int();
            if (topColors.containsKey(a)) {
                topColors.put(a, topColors.get(a) + 1);
            } else {
                topColors.put(a, 1);
            }
            a = Int();
            if (bottomColors.containsKey(a)) {
                bottomColors.put(a, bottomColors.get(a) + 1);
            } else {
                bottomColors.put(a, 1);
            }
        }
        int leastMoves = Integer.MAX_VALUE;

        Set<Integer> colors = new HashSet<Integer>();
        colors.addAll(bottomColors.keySet());
        colors.addAll(topColors.keySet());

        for (Integer col : colors) {
            Integer ai = topColors.get(col);
            Integer bi = bottomColors.get(col);
            int a = ai == null ? 0 : ai;
            int b = bi == null ? 0 : bi;
            if (a + b >= hn) {
                int moves = Math.max(0, hn - a);
                if (moves < leastMoves) {
                    leastMoves = moves;
                }
                if (leastMoves == 0) {
                    break;
                }
            }
        }

        System.out.println(leastMoves == Integer.MAX_VALUE ? -1 : leastMoves);
    }

    public static int Int() {
        return scanner.nextInt();
    }

}


import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Cards {

    static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = Int();
        int hn = n % 2 == 0 ? n / 2 : n / 2 + 1;
        Map<Integer, Integer> topColors = new HashMap<Integer, Integer>();
        Map<Integer, Integer> bottomColors = new HashMap<Integer, Integer>();

        for (int i = 0; i < n; i++) {
            int a = Int();
            if (topColors.containsKey(a)) {
                topColors.put(a, topColors.get(a) + 1);
            } else {
                topColors.put(a, 1);
            }
            a = Int();
            if (bottomColors.containsKey(a)) {
                bottomColors.put(a, bottomColors.get(a) + 1);
            } else {
                bottomColors.put(a, 1);
            }
        }
        int leastMoves = Integer.MAX_VALUE;

        for (Integer col : topColors.keySet()) {
            Integer ai = topColors.get(col);
            Integer bi = bottomColors.get(col);
            int a = ai == null ? 0 : ai;
            int b = bi == null ? 0 : bi;
            if (a + b >= hn) {
                int moves = Math.max(0, hn - a);
                if (moves < leastMoves) {
                    leastMoves = moves;
                }
                if (leastMoves == 0) {
                    break;
                }
            }
        }

        for (Integer col : bottomColors.keySet()) {
            Integer ai = topColors.get(col);
            Integer bi = bottomColors.get(col);
            int a = ai == null ? 0 : ai;
            int b = bi == null ? 0 : bi;
            if (a + b >= hn) {
                int moves = Math.max(0, hn - a);
                if (moves < leastMoves) {
                    leastMoves = moves;
                }
                if (leastMoves == 0) {
                    break;
                }
            }
        }

        System.out.println(leastMoves == Integer.MAX_VALUE ? -1 : leastMoves);
    }

    public static int Int() {
        return scanner.nextInt();
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

public class Cards2 {

	BufferedReader in;
	StringTokenizer st;
	PrintWriter out;

	public static void main(String[] args) {
		Cards2 t = new Cards2();
		t.init();
	}

	void run() throws Exception {
		int n = Int();
		int hn = n % 2 == 0 ? n / 2 : n / 2 + 1;
		Map<Integer, Integer> topColors = new HashMap<Integer, Integer>();
		Map<Integer, Integer> bottomColors = new HashMap<Integer, Integer>();
		Map<Integer, Integer> duplicColors = new HashMap<Integer, Integer>();

		for (int i = 0; i < n; i++) {
			int a = Int();
			if (topColors.containsKey(a)) {
				topColors.put(a, topColors.get(a) + 1);
			} else {
				topColors.put(a, 1);
			}
			int b = Int();
			if (bottomColors.containsKey(b)) {
				bottomColors.put(b, bottomColors.get(b) + 1);
			} else {
				bottomColors.put(b, 1);
			}
			if (a == b) {
				if (duplicColors.containsKey(a)) {
					duplicColors.put(a, duplicColors.get(a) + 1);
				} else {
					duplicColors.put(a, 1);
				}
			}
		}
		int leastMoves = Integer.MAX_VALUE;

		Set<Integer> colors = new HashSet<Integer>();
		colors.addAll(bottomColors.keySet());
		colors.addAll(topColors.keySet());

		for (Integer col : colors) {
			Integer ai = topColors.get(col);
			Integer bi = bottomColors.get(col);
			Integer ci = duplicColors.get(col);
			int a = ai == null ? 0 : ai;
			int b = bi == null ? 0 : bi;
			int c = ci == null ? 0 : ci;
			if (a + b - c >= hn) {
				int moves = Math.max(0, hn - a);
				if (moves < leastMoves) {
					leastMoves = moves;
				}
				if (leastMoves == 0) {
					break;
				}
			}
		}

		PrintLn(leastMoves == Integer.MAX_VALUE ? -1 : leastMoves);
	}

	void init() {
		try {
			Locale.setDefault(Locale.US);
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			run();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	String next() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	int Int() throws Exception {
		return Integer.parseInt(next());
	}

	long Long() throws Exception {
		return Long.parseLong(next());
	}

	double Double() throws Exception {
		return Double.parseDouble(next());
	}

	void PrintLn(Object line) {
		out.println(line);
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Cards2 {

    BufferedReader in;
    StringTokenizer st;
    PrintWriter out;

    public static void main(String[] args) {
        Cards2 t = new Cards2();
        t.init();
    }

    void run() throws Exception {
        int n = Int();
        int hn = n % 2 == 0 ? n / 2 : n / 2 + 1;
        Map<Integer, Integer> topColors = new TreeMap<Integer, Integer>();
        Map<Integer, Integer> bottomColors = new TreeMap<Integer, Integer>();
        Map<Integer, Integer> duplicColors = new TreeMap<Integer, Integer>();
        Set<Integer> colors = new TreeSet<Integer>();

        for (int i = 0; i < n; i++) {
            int a = Int();
            if (topColors.containsKey(a)) {
                topColors.put(a, topColors.get(a) + 1);
            } else {
                topColors.put(a, 1);
            }
            int b = Int();
            if (bottomColors.containsKey(b)) {
                bottomColors.put(b, bottomColors.get(b) + 1);
            } else {
                bottomColors.put(b, 1);
            }
            if (a == b) {
                if (duplicColors.containsKey(a)) {
                    duplicColors.put(a, duplicColors.get(a) + 1);
                } else {
                    duplicColors.put(a, 1);
                }
            }
            colors.add(a);
            colors.add(b);
        }
        int leastMoves = Integer.MAX_VALUE;

        for (Integer col : colors) {
            Integer ai = topColors.get(col);
            Integer bi = bottomColors.get(col);
            Integer ci = duplicColors.get(col);
            int a = ai == null ? 0 : ai;
            int b = bi == null ? 0 : bi;
            int c = ci == null ? 0 : ci;
            if (a + b - c >= hn) {
                int moves = Math.max(0, hn - a);
                if (moves < leastMoves) {
                    leastMoves = moves;
                }
                if (leastMoves == 0) {
                    break;
                }
            }
        }

        PrintLn(leastMoves == Integer.MAX_VALUE ? -1 : leastMoves);
    }

    void init() {
        try {
            Locale.setDefault(Locale.US);
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
            run();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    int Int() throws Exception {
        return Integer.parseInt(next());
    }

    long Long() throws Exception {
        return Long.parseLong(next());
    }

    double Double() throws Exception {
        return Double.parseDouble(next());
    }

    void PrintLn(Object line) {
        out.println(line);
    }

}


import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Cards {

    static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = Int();
        int hn = n % 2 == 0 ? n / 2 : n / 2 + 1;
        Map<Integer, Integer> topColors = new HashMap<Integer, Integer>();
        Map<Integer, Integer> bottomColors = new HashMap<Integer, Integer>();
        Map<Integer, Integer> duplicColors = new HashMap<Integer, Integer>();

        for (int i = 0; i < n; i++) {
            int a = Int();
            if (topColors.containsKey(a)) {
                topColors.put(a, topColors.get(a) + 1);
            } else {
                topColors.put(a, 1);
            }
            int b = Int();
            if (bottomColors.containsKey(b)) {
                bottomColors.put(b, bottomColors.get(b) + 1);
            } else {
                bottomColors.put(b, 1);
            }
            if (a == b) {
                if (duplicColors.containsKey(a)) {
                    duplicColors.put(a, duplicColors.get(a) + 1);
                } else {
                    duplicColors.put(a, 1);
                }
            }
        }
        int leastMoves = Integer.MAX_VALUE;

        Set<Integer> colors = new HashSet<Integer>();
        colors.addAll(bottomColors.keySet());
        colors.addAll(topColors.keySet());

        for (Integer col : colors) {
            Integer ai = topColors.get(col);
            Integer bi = bottomColors.get(col);
            Integer ci = duplicColors.get(col);
            int a = ai == null ? 0 : ai;
            int b = bi == null ? 0 : bi;
            int c = ci == null ? 0 : ci;
            if (a + b - c >= hn) {
                int moves = Math.max(0, hn - a);
                if (moves < leastMoves) {
                    leastMoves = moves;
                }
                if (leastMoves == 0) {
                    break;
                }
            }
        }

        System.out.println(leastMoves == Integer.MAX_VALUE ? -1 : leastMoves);
    }

    public static int Int() {
        return scanner.nextInt();
    }

}


import java.io.*;
import java.util.*;

public class Main {
	int X[], dep;

	int Id(int v) {
		int l = 0, r = dep, mid;
		while (r - l > 1) {
			mid = (l + r) >> 1;
			if (X[mid] <= v)
				l = mid;
			else
				r = mid;
		}
		return l;
	}

	void run() throws IOException {
		int n = cin.nextInt();
		X = new int[n + n];
		int a[] = new int[n], b[] = new int[n];

		for (int i = 0; i < n; ++i) {
			a[i] = cin.nextInt();
			b[i] = cin.nextInt();
			X[i * 2] = a[i];
			X[i * 2 + 1] = b[i];
		}

		Arrays.sort(X);
		dep = 1;
		for (int i = 1; i < n * 2; ++i)
			if (X[i] != X[i - 1])
				X[dep++] = X[i];

		int ar[] = new int[dep], br[] = new int[dep];
		for (int i = 0; i < n; ++i) {
			++ar[Id(a[i])];
			if (a[i] == b[i])
				continue;
			++br[Id(b[i])];
		}

		int ans = -1;
		for (int i = 0; i < dep; ++i) {
			if (ar[i] * 2 >= n) {
				ans = 0;
				break;
			}
			if (ar[i] * 2 + br[i] * 2 >= n) {
				// System.out.println(X[i]);
				int need = (n - ar[i] * 2) / 2;
				if (need * 2 + ar[i] * 2 < n)
					++need;

				if (ans == -1)
					ans = need;
				else
					ans = Math.min(ans, need);
			}
		}
		out.println(ans);
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	Main() {
		cin = new InputReader(System.in);
		// cin = new Scanner(System.in);
		out = new PrintWriter(System.out);
	}

	PrintWriter out;
	InputReader cin;

	// Scanner cin;

	class InputReader {
		InputReader(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			// try {
			// reader = new BufferedReader(new FileReader("input.txt"));
			// } catch (FileNotFoundException ex) {
			// }
			tokenizer = new StringTokenizer("");
		}

		private String next() throws IOException {
			while (!tokenizer.hasMoreTokens()) {
				tokenizer = new StringTokenizer(reader.readLine());
			}
			return tokenizer.nextToken();
		}

		public Integer nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		private BufferedReader reader;
		private StringTokenizer tokenizer;
	}
}


//package contest_129_div2;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
 * Date     : Jul 11, 2012
 * Time     : 6:40:21 PM
 * Email    : denys.astanin@gmail.com
 */

public class D {
	public static void main(String[] args) throws IOException {
		new D().run();
	}

	int nextInt() throws IOException {
		in.nextToken();
		return (int) in.nval;
	}

	String nextString() throws IOException {
		in.nextToken();
		return (String) in.sval;
	}

	StreamTokenizer in;
	Writer writer;
	Reader reader;
	class Node implements Comparable<Node> {
		private boolean left;
		private int number;
		public Node(int number, boolean left) {
			this.number = number;
			this.left = left;
		}
		@Override
		public int compareTo(Node o) {
			return number - o.number;
		}
		@Override
		public String toString() {
			return number + "";
		}
	}
	void run() throws IOException {
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		reader = oj ? new InputStreamReader(System.in, "ISO-8859-1")
				: new FileReader("src/contest_129_div2/D.txt");
		writer = new OutputStreamWriter(System.out, "ISO-8859-1");
		in = new StreamTokenizer(new BufferedReader(reader));
		PrintWriter out = new PrintWriter(writer);
		int n = nextInt();
		List<Node> list = new ArrayList<Node>();
		for (int i = 0; i < n; i++) {
			int left = nextInt();
			int right = nextInt();
			if (right != left)
				list.add(new Node(right, false));
		}
		Collections.sort(list);
		int half = n / 2 + (n % 2 == 0 ? 0 : 1);
		int answ = Integer.MAX_VALUE;
		int type = 0;
		int currentCount = 0;
		int left = 0;
		int right = 0;
		for (int i = 0; i < list.size(); i++) {
			if (list.get(i).number != type) {
				if (currentCount >= half) {
					if (left >= half) {
						answ = 0;
					} else {
						int temp = (half - left);
						answ = Math.min(answ, temp);
					}
				}
				type = list.get(i).number;
				currentCount = 0;
				left = 0;
				right = 0;
			}
			left += list.get(i).left ? 1 : 0;
			right += list.get(i).left ? 0 : 1;
			currentCount++;
		}
		if (currentCount >= half) {
			if (left >= half) {
				answ = 0;
			} else {
				int temp = (half - left);
				answ = Math.min(answ, temp);
			}
		}
		out.println(answ == Integer.MAX_VALUE ? -1 : answ);
		out.flush();
		out.close();
	}
}


//package contest_129_div2;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.io.Writer;
import java.util.Arrays;
/**
 * Date     : Jul 11, 2012
 * Time     : 6:40:21 PM
 * Email    : denys.astanin@gmail.com
 */

public class D {
	public static void main(String[] args) throws IOException {
		new D().run();
	}

	int nextInt() throws IOException {
		in.nextToken();
		return (int) in.nval;
	}

	String nextString() throws IOException {
		in.nextToken();
		return (String) in.sval;
	}

	StreamTokenizer in;
	Writer writer;
	Reader reader;
	class Node implements Comparable<Node> {
		private boolean left;
		private int number;
		public Node(int number, boolean left) {
			this.number = number;
			this.left = left;
		}
		@Override
		public int compareTo(Node o) {
			return number - o.number;
		}
		@Override
		public String toString() {
			return number + "";
		}
	}
	void run() throws IOException {
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		reader = oj ? new InputStreamReader(System.in, "ISO-8859-1")
				: new FileReader("src/contest_129_div2/D.txt");
		writer = new OutputStreamWriter(System.out, "ISO-8859-1");
		in = new StreamTokenizer(new BufferedReader(reader));
		PrintWriter out = new PrintWriter(writer);
		int n = nextInt();
		Node[] list = new Node[2 * n];
		for (int i = 0; i < n; i++) {
			int left = nextInt();
			int right = nextInt();
			list[i * 2] = new Node(left, true);
			list[i * 2 + 1] = new Node(right, false);
		}
		Arrays.sort(list);
		int half = n / 2 + (n % 2 == 0 ? 0 : 1);
		int answ = Integer.MAX_VALUE;
		int type = 0;
		int currentCount = 0;
		int left = 0;
		int right = 0;
		for (int i = 0; i < 2 * n; i++) {
			if (list[i].number != type) {
				if (currentCount >= half) {
					if (left >= half) {
						answ = 0;
					} else {
						int temp = (half - left);
						answ = Math.min(answ, temp);
					}
				}
				type = list[i].number;
				currentCount = 0;
				left = 0;
				right = 0;
			}
			left += list[i].left ? 1 : 0;
			right += list[i].left ? 0 : 1;
			currentCount++;
		}
		out.println(answ);
		out.flush();
		out.close();
	}
}


//package contest_129_div2;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.io.Writer;
import java.util.Arrays;
/**
 * Date     : Jul 11, 2012
 * Time     : 6:40:21 PM
 * Email    : denys.astanin@gmail.com
 */

public class D {
	public static void main(String[] args) throws IOException {
		new D().run();
	}

	int nextInt() throws IOException {
		in.nextToken();
		return (int) in.nval;
	}

	String nextString() throws IOException {
		in.nextToken();
		return (String) in.sval;
	}

	StreamTokenizer in;
	Writer writer;
	Reader reader;
	class Node implements Comparable<Node> {
		private boolean left;
		private int number;
		public Node(int number, boolean left) {
			this.number = number;
			this.left = left;
		}
		@Override
		public int compareTo(Node o) {
			return number - o.number;
		}
		@Override
		public String toString() {
			return number + "";
		}
	}
	void run() throws IOException {
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		reader = oj ? new InputStreamReader(System.in, "ISO-8859-1")
				: new FileReader("src/contest_129_div2/D.txt");
		writer = new OutputStreamWriter(System.out, "ISO-8859-1");
		in = new StreamTokenizer(new BufferedReader(reader));
		PrintWriter out = new PrintWriter(writer);
		int n = nextInt();
		Node[] list = new Node[2 * n];
		for (int i = 0; i < n; i++) {
			int left = nextInt();
			int right = nextInt();
			list[i * 2] = new Node(left, true);
			list[i * 2 + 1] = new Node(right, false);
		}
		Arrays.sort(list);
		int half = n / 2 + (n % 2 == 0 ? 0 : 1);
		int answ = Integer.MAX_VALUE;
		int type = 0;
		int currentCount = 0;
		int left = 0;
		int right = 0;
		for (int i = 0; i < 2 * n; i++) {
			if (list[i].number != type) {
				if (currentCount >= half) {
					if (left >= half) {
						answ = 0;
					} else {
						int temp = (half - left);
						answ = Math.min(answ, temp);
					}
				}
				type = list[i].number;
				currentCount = 0;
				left = 0;
				right = 0;
			}
			left += list[i].left ? 1 : 0;
			right += list[i].left ? 0 : 1;
			currentCount++;
		}
		if (currentCount >= half) {
			if (left >= half) {
				answ = 0;
			} else {
				int temp = (half - left);
				answ = Math.min(answ, temp);
			}
		}
		out.println(answ == Integer.MAX_VALUE ? -1 : answ);
		out.flush();
		out.close();
	}
}


//package contest_129_div2;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
 * Date     : Jul 11, 2012
 * Time     : 6:40:21 PM
 * Email    : denys.astanin@gmail.com
 */

public class D {
	public static void main(String[] args) throws IOException {
		new D().run();
	}

	int nextInt() throws IOException {
		in.nextToken();
		return (int) in.nval;
	}

	String nextString() throws IOException {
		in.nextToken();
		return (String) in.sval;
	}

	StreamTokenizer in;
	Writer writer;
	Reader reader;
	class Node implements Comparable<Node> {
		private boolean left;
		private int number;
		public Node(int number, boolean left) {
			this.number = number;
			this.left = left;
		}
		@Override
		public int compareTo(Node o) {
			return number - o.number;
		}
		@Override
		public String toString() {
			return number + "";
		}
	}
	void run() throws IOException {
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		reader = oj ? new InputStreamReader(System.in, "ISO-8859-1")
				: new FileReader("src/contest_129_div2/D.txt");
		writer = new OutputStreamWriter(System.out, "ISO-8859-1");
		in = new StreamTokenizer(new BufferedReader(reader));
		PrintWriter out = new PrintWriter(writer);
		int n = nextInt();
		List<Node> list = new ArrayList<Node>();
		for (int i = 0; i < n; i++) {
			int left = nextInt();
			int right = nextInt();
			list.add(new Node(left, true));
			if (right != left)
				list.add(new Node(right, false));
		}
		Collections.sort(list);
		int half = n / 2 + (n % 2 == 0 ? 0 : 1);
		int answ = Integer.MAX_VALUE;
		int type = 0;
		int currentCount = 0;
		int left = 0;
		int right = 0;
		for (int i = 0; i < list.size(); i++) {
			if (list.get(i).number != type) {
				if (currentCount >= half) {
					if (left >= half) {
						answ = 0;
					} else {
						int temp = (half - left);
						answ = Math.min(answ, temp);
					}
				}
				currentCount = 0;
				left = 0;
				right = 0;
				type = list.get(i).number;
			}
			left += list.get(i).left ? 1 : 0;
			right += list.get(i).left ? 0 : 1;
			currentCount++;
		}
		if (currentCount >= half) {
			if (left >= half) {
				answ = 0;
			} else {
				int temp = (half - left);
				answ = Math.min(answ, temp);
			}
		}
		out.println(answ == Integer.MAX_VALUE ? -1 : answ);
		out.flush();
		out.close();
	}
}


//package contest_129_div2;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.io.Writer;
import java.util.Arrays;
/**
 * Date     : Jul 11, 2012
 * Time     : 6:40:21 PM
 * Email    : denys.astanin@gmail.com
 */

public class D {
	public static void main(String[] args) throws IOException {
		new D().run();
	}

	int nextInt() throws IOException {
		in.nextToken();
		return (int) in.nval;
	}

	String nextString() throws IOException {
		in.nextToken();
		return (String) in.sval;
	}

	StreamTokenizer in;
	Writer writer;
	Reader reader;
	class Node implements Comparable<Node> {
		private boolean left;
		private int number;
		public Node(int number, boolean left) {
			this.number = number;
			this.left = left;
		}
		@Override
		public int compareTo(Node o) {
			return number - o.number;
		}
		@Override
		public String toString() {
			return number + "";
		}
	}
	void run() throws IOException {
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		reader = oj ? new InputStreamReader(System.in, "ISO-8859-1")
				: new FileReader("src/contest_129_div2/D.txt");
		writer = new OutputStreamWriter(System.out, "ISO-8859-1");
		in = new StreamTokenizer(new BufferedReader(reader));
		PrintWriter out = new PrintWriter(writer);
		int n = nextInt();
		Node[] list = new Node[2 * n];
		for (int i = 0; i < n; i++) {
			int left = nextInt();
			int right = nextInt();
			list[i * 2] = new Node(left, true);
			list[i * 2 + 1] = new Node(right, false);
		}
		Arrays.sort(list);
		int half = n / 2 + (n % 2 == 0 ? 0 : 1);
		int answ = Integer.MAX_VALUE;
		int type = 0;
		int currentCount = 0;
		int left = 0;
		int right = 0;
		for (int i = 0; i < 2 * n; i++) {
			if (list[i].number != type) {
				if (currentCount >= half) {
					if (left >= half) {
						answ = 0;
					} else {
						int temp = (half - left);
						answ = Math.min(answ, temp);
					}
				}
				type = list[i].number;
				currentCount = 0;
				left = 0;
				right = 0;
			}
			left += list[i].left ? 1 : 0;
			right += list[i].left ? 0 : 1;
			currentCount++;
		}
		if (currentCount >= half) {
			if (left >= half) {
				answ = 0;
			} else {
				int temp = (half - left);
				answ = Math.min(answ, temp);
			}
		}
		out.println(answ);
		out.flush();
		out.close();
	}
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        InputScannerzzz22v s = new InputScannerzzz22v(System.in);

        int n = s.nextInt();
        HashMap<Integer, Integer> front = new HashMap<Integer, Integer>();
        HashMap<Integer, Integer> back = new HashMap<Integer, Integer>();
        HashSet<Integer> colors = new HashSet<Integer>();
        for (int i = 0; i < n; i++) {
            int f = s.nextInt();
            if(front.containsKey(f))
                front.put(f, front.get(f)+1);
            else front.put(f, 1);
            int b = s.nextInt();
            if(back.containsKey(b))
                back.put(b, back.get(b)+1);
            else back.put(b, 1);
            colors.add(f);
            colors.add(b);
        }

        int best = Integer.MAX_VALUE;
        for(int color : colors){

            int f = 0;
            int b = 0;
            if(front.containsKey(color))
                f = front.get(color);
            if(back.containsKey(color))
                b = back.get(color);
//          System.out.println(color+" :  "+f+"  "+b);

            int half = (n+1)/2;

            if(f>=half || b >=half){
                best = 0;
            }
            else if(f+b >= half){
                int res = half - f;
                best = Math.min(best, res);
            }

        }
        System.out.println(best);

    }

}

class InputScannerzzz22v {
    BufferedReader br;
    StringTokenizer strtok = null;

    public InputScannerzzz22v(InputStream stream) {
        br = new BufferedReader(new InputStreamReader(stream));

    }

    public InputScannerzzz22v(File file) throws FileNotFoundException {
        br = new BufferedReader(new FileReader(file));
    }

    public String next() {
        if (strtok == null || !strtok.hasMoreTokens()) {
            try {
                strtok = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return strtok.nextToken();
    }

    public int nextInt() {
        int i;
        try {
            i = Integer.parseInt(next());
        } catch (NumberFormatException e) {
            throw new RuntimeException(e);
        }
        return i;
    }

    public String nextLine() {
        if (strtok == null || !strtok.hasMoreTokens()) {
            try {
                strtok = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return strtok.nextToken("\n").trim();
    }

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        InputScannerzzz22v s = new InputScannerzzz22v(System.in);

        int n = s.nextInt();
        HashMap<Integer, Integer> front = new HashMap<Integer, Integer>();
        HashMap<Integer, Integer> back = new HashMap<Integer, Integer>();
        HashSet<Integer> colors = new HashSet<Integer>();
        HashMap<Integer, Integer> eq = new HashMap<Integer,Integer>();
        for (int i = 0; i < n; i++) {

            int f = s.nextInt();
            if(front.containsKey(f))
                front.put(f, front.get(f)+1);
            else front.put(f, 1);

            int b = s.nextInt();
            if(back.containsKey(b))
                back.put(b, back.get(b)+1);
            else back.put(b, 1);
            colors.add(f);
            colors.add(b);

            if(f==b){
                if(eq.containsKey(f))
                    eq.put(f, eq.get(f)+1);
                else eq.put(f, 1);
            }
        }

        int best = Integer.MAX_VALUE;
        for(int color : colors){

            int f = 0;
            int b = 0;
            int eqq = 0;
            if(front.containsKey(color))
                f = front.get(color);
            if(back.containsKey(color))
                b = back.get(color);
            if(eq.containsKey(color))
                eqq = eq.get(color);
            int half = (n+1)/2;

            b-= eqq;

            if(f>=half){
                best = 0;
            }
            else if(f + b>= half){
                int res = half - f;
                best = Math.min(best, res);
            }

        }
        if(best==Integer.MAX_VALUE)
            System.out.println("-1");
        else System.out.println(best);

    }

}

class InputScannerzzz22v {
    BufferedReader br;
    StringTokenizer strtok = null;

    public InputScannerzzz22v(InputStream stream) {
        br = new BufferedReader(new InputStreamReader(stream));

    }

    public InputScannerzzz22v(File file) throws FileNotFoundException {
        br = new BufferedReader(new FileReader(file));
    }

    public String next() {
        if (strtok == null || !strtok.hasMoreTokens()) {
            try {
                strtok = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return strtok.nextToken();
    }

    public int nextInt() {
        int i;
        try {
            i = Integer.parseInt(next());
        } catch (NumberFormatException e) {
            throw new RuntimeException(e);
        }
        return i;
    }

    public String nextLine() {
        if (strtok == null || !strtok.hasMoreTokens()) {
            try {
                strtok = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return strtok.nextToken("\n").trim();
    }

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main{

    public static void main(String[] args) {
        InputScannerzzz22v s = new InputScannerzzz22v(System.in);

        int n = s.nextInt();
        HashMap<Integer, Integer> front = new HashMap<Integer, Integer>();
        HashMap<Integer, Integer> back = new HashMap<Integer, Integer>();
        HashSet<Integer> colors = new HashSet<Integer>();
        for (int i = 0; i < n; i++) {
            int f = s.nextInt();
            if(front.containsKey(f))
                front.put(f, front.get(f)+1);
            else front.put(f, 1);
            int b = s.nextInt();
            if(back.containsKey(b))
                back.put(b, back.get(b)+1);
            else back.put(b, 1);
            colors.add(f);
            colors.add(b);
        }

        int best = Integer.MAX_VALUE;
        for(int color : colors){

            int f = 0;
            int b = 0;
            if(front.containsKey(color))
                f = front.get(color);
            if(back.containsKey(color))
                b = back.get(color);
            int half = (n+1)/2;

            if(f>=half){
                best = 0;
            }
            else if(f+b >= half){
                int res = half - f;
                best = Math.min(best, res);
            }

        }
        if(best==Integer.MAX_VALUE)
            System.out.println("-1");
        else System.out.println(best);

    }

}

class InputScannerzzz22v {
    BufferedReader br;
    StringTokenizer strtok = null;

    public InputScannerzzz22v(InputStream stream) {
        br = new BufferedReader(new InputStreamReader(stream));

    }

    public InputScannerzzz22v(File file) throws FileNotFoundException {
        br = new BufferedReader(new FileReader(file));
    }

    public String next() {
        if (strtok == null || !strtok.hasMoreTokens()) {
            try {
                strtok = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return strtok.nextToken();
    }

    public int nextInt() {
        int i;
        try {
            i = Integer.parseInt(next());
        } catch (NumberFormatException e) {
            throw new RuntimeException(e);
        }
        return i;
    }

    public String nextLine() {
        if (strtok == null || !strtok.hasMoreTokens()) {
            try {
                strtok = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return strtok.nextToken("\n").trim();
    }

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        InputScannerzzz22v s = new InputScannerzzz22v(System.in);

        int n = s.nextInt();
        HashMap<Integer, Integer> front = new HashMap<Integer, Integer>();
        HashMap<Integer, Integer> back = new HashMap<Integer, Integer>();
        HashSet<Integer> colors = new HashSet<Integer>();
        for (int i = 0; i < n; i++) {
            int f = s.nextInt();
            if(front.containsKey(f))
                front.put(f, front.get(f)+1);
            else front.put(f, 1);
            int b = s.nextInt();
            if(back.containsKey(b))
                back.put(b, back.get(b)+1);
            else back.put(b, 1);
            colors.add(f);
            colors.add(b);
        }

        int best = Integer.MAX_VALUE;
        for(int color : colors){

            int f = 0;
            int b = 0;
            if(front.containsKey(color))
                f = front.get(color);
            if(back.containsKey(color))
                b = back.get(color);
            int half = (n+1)/2;

            if(f>=half){
                best = 0;
            }
            else if(f+b >= half){
                int res = half - f;
                best = Math.min(best, res);
            }

        }
        System.out.println(best);

    }

}

class InputScannerzzz22v {
    BufferedReader br;
    StringTokenizer strtok = null;

    public InputScannerzzz22v(InputStream stream) {
        br = new BufferedReader(new InputStreamReader(stream));

    }

    public InputScannerzzz22v(File file) throws FileNotFoundException {
        br = new BufferedReader(new FileReader(file));
    }

    public String next() {
        if (strtok == null || !strtok.hasMoreTokens()) {
            try {
                strtok = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return strtok.nextToken();
    }

    public int nextInt() {
        int i;
        try {
            i = Integer.parseInt(next());
        } catch (NumberFormatException e) {
            throw new RuntimeException(e);
        }
        return i;
    }

    public String nextLine() {
        if (strtok == null || !strtok.hasMoreTokens()) {
            try {
                strtok = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return strtok.nextToken("\n").trim();
    }

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main{

    public static void main(String[] args) {
        InputScannerzzz22v s = new InputScannerzzz22v(System.in);

        int n = s.nextInt();
        TreeMap<Integer, Integer> front = new TreeMap<Integer, Integer>();
        TreeMap<Integer, Integer> back = new TreeMap<Integer, Integer>();
        TreeSet<Integer> colors = new TreeSet<Integer>();
        TreeMap<Integer, Integer> eq = new TreeMap<Integer,Integer>();
        for (int i = 0; i < n; i++) {

            int f = s.nextInt();
            if(front.containsKey(f))
                front.put(f, front.get(f)+1);
            else front.put(f, 1);

            int b = s.nextInt();
            if(back.containsKey(b))
                back.put(b, back.get(b)+1);
            else back.put(b, 1);
            colors.add(f);
            colors.add(b);

            if(f==b){
                if(eq.containsKey(f))
                    eq.put(f, eq.get(f)+1);
                else eq.put(f, 1);
            }
        }

        int best = Integer.MAX_VALUE;
        for(int color : colors){

            int f = 0;
            int b = 0;
            int eqq = 0;
            if(front.containsKey(color))
                f = front.get(color);
            if(back.containsKey(color))
                b = back.get(color);
            if(eq.containsKey(color))
                eqq = eq.get(color);
            int half = (n+1)/2;

            b-= eqq;

            if(f>=half){
                best = 0;
            }
            else if(f + b>= half){
                int res = half - f;
                best = Math.min(best, res);
            }

        }
        if(best==Integer.MAX_VALUE)
            System.out.println("-1");
        else System.out.println(best);

    }

}

class InputScannerzzz22v {
    BufferedReader br;
    StringTokenizer strtok = null;

    public InputScannerzzz22v(InputStream stream) {
        br = new BufferedReader(new InputStreamReader(stream));

    }

    public InputScannerzzz22v(File file) throws FileNotFoundException {
        br = new BufferedReader(new FileReader(file));
    }

    public String next() {
        if (strtok == null || !strtok.hasMoreTokens()) {
            try {
                strtok = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return strtok.nextToken();
    }

    public int nextInt() {
        int i;
        try {
            i = Integer.parseInt(next());
        } catch (NumberFormatException e) {
            throw new RuntimeException(e);
        }
        return i;
    }

    public String nextLine() {
        if (strtok == null || !strtok.hasMoreTokens()) {
            try {
                strtok = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return strtok.nextToken("\n").trim();
    }

}


import java.util.*;

public class D{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[][] card = new int[n][2];
		for(int i = 0; i < n; i++){
			card[i][0] = stdIn.nextInt();
			card[i][1] = stdIn.nextInt();
		}
		Map<Integer, Integer> front = new HashMap<Integer, Integer>();
		Map<Integer, Integer> num = new HashMap<Integer, Integer>();
		for(int i = 0; i < n; i++){
			int x = (front.get(card[i][0]) == null) ? 1 : front.get(card[i][0])+1;
			front.put(card[i][0], x);
			int y = (num.get(card[i][1]) == null) ? 1 : num.get(card[i][1])+1;
			num.put(card[i][1], y);
			if( card[i][0] != card[i][1] ){
				int z = (num.get(card[i][0]) == null) ? 1 : num.get(card[i][0])+1;
				num.put(card[i][0], z);
			}
		}
		int max = 0;
		for(Integer x : front.keySet()){
			if( front.get(x) > max && num.get(x) > Math.ceil(n/2) ){
				max = front.get(x);
			}
		}
		if( max == 0 ){
			System.out.println(-1);
			return;
		}

		int ans = Math.max(0, (int)Math.ceil(n/2) - max);
		System.out.println(ans);
	}
}


import java.util.*;

public class D{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[][] card = new int[n][2];
		for(int i = 0; i < n; i++){
			card[i][0] = stdIn.nextInt();
			card[i][1] = stdIn.nextInt();
		}
		Map<Integer, Integer> front = new HashMap<Integer, Integer>();
		Map<Integer, Integer> num = new HashMap<Integer, Integer>();
		for(int i = 0; i < n; i++){
			int x = (front.get(card[i][0]) == null) ? 1 : front.get(card[i][0])+1;
			front.put(card[i][0], x);
			int y = (num.get(card[i][1]) == null) ? 1 : num.get(card[i][1])+1;
			num.put(card[i][1], y);
			if( card[i][0] != card[i][1] ){
				int z = (num.get(card[i][0]) == null) ? 1 : num.get(card[i][0])+1;
				num.put(card[i][0], z);
			}
		}
		int max = -1;

		for(Integer x : num.keySet()){
			if( num.get(x) >= Math.ceil((double)n/2) ){
				if( front.get(x) == null ){
					max = Math.max(0, max);
				} else if( front.get(x) > max ){
					max = front.get(x);
				}
			}
		}
		if( max == -1 ){
			System.out.println(-1);
			return;
		}

		int ans = Math.max(0, (int)Math.ceil((double)n/2) - max);
		System.out.println(ans);
	}
}


import java.util.*;
import java.io.*;

public class D extends Template{
	public void solve() throws IOException{
		int n = nextInt();
		int[][] card = new int[n][2];
		for(int i = 0; i < n; i++){
			card[i][0] = nextInt();
			card[i][1] = nextInt();
		}
		Map<Integer, Integer> front = new HashMap<Integer, Integer>();
		Map<Integer, Integer> num = new HashMap<Integer, Integer>();
		for(int i = 0; i < n; i++){
			int x = (front.get(card[i][0]) == null) ? 1 : front.get(card[i][0])+1;
			front.put(card[i][0], x);
			int y = (num.get(card[i][1]) == null) ? 1 : num.get(card[i][1])+1;
			num.put(card[i][1], y);
			if( card[i][0] != card[i][1] ){
				int z = (num.get(card[i][0]) == null) ? 1 : num.get(card[i][0])+1;
				num.put(card[i][0], z);
			}
		}
		int max = -1;

		for(Integer x : num.keySet()){
			if( num.get(x) >= Math.ceil((double)n/2) ){
				if( front.get(x) == null ){
					max = Math.max(0, max);
				} else if( front.get(x) > max ){
					max = front.get(x);
				}
			}
		}
		if( max == -1 ){
			writer.println(-1);
			return;
		}

		int ans = Math.max(0, (int)Math.ceil((double)n/2) - max);
		writer.println(ans);
	}
	public static void main(String[] args){
		new D().run();
	}
}
abstract class Template implements Runnable {
	public void solve() throws IOException {

	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run(){
		try{
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e){
			e.printStackTrace();
			System.exit(1);
		}
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public String nextToken() throws IOException {
		while( tokenizer == null || !tokenizer.hasMoreTokens() ){
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}