import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
    static class Reader
    {
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;}
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];}
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;}
        public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();}
        public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;}
        public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;}
        public double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; }
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; }
        public int[] arr(int n){int[] ret = new int[n];for (int i = 0; i < n; i++) {ret[i] = i();}return ret;}
    }

    ///////////////////////////////////////////////////////////////////////////////////////////
    //    RRRRRRRRR            AAA             HHH     HHH     IIIIIIIIIIIII   LLL           //
    //    RR    RRR           AAAAA            HHH     HHH      IIIIIIIIIII    LLL           //
    //    RR   RRR           AAAAAAA           HHH     HHH          III        LLL           //
    //    RR  RRR           AAA   AAA          HHHHHHHHHHH          III        LLL           //
    //    RRRRRR           AAA     AAA         HHHHHHHHHHH          III        LLL           //
    //    RR  RRR         AAAAAAAAAAAAA        HHH     HHH          III        LLL           //
    //    RR    RRR      AAA         AAA       HHH     HHH      IIIIIIIIIII    LLLLLLLLLLLL  //
    //    RR     RRR    AAA           AAA      HHH     HHH     IIIIIIIIIIIII   LLLLLLLLLLLL  //
    ///////////////////////////////////////////////////////////////////////////////////////////

    public static void main(String[] args)throws IOException
    {
        PrintWriter out= new PrintWriter(System.out);
        Reader sc=new Reader();
        int n=sc.i();
        HashMap<Integer,Integer> hmup=new HashMap<>();
        HashMap<Integer,Integer> hmdown=new HashMap<>();
        for(int i=0;i<n;i++)
        {
            int a=sc.i();
            int b=sc.i();
            hmup.put(a,hmup.getOrDefault(a,0)+1);
            if(a!=b)
            hmdown.put(b,hmdown.getOrDefault(b,0)+1);
        }
        int ans=2000000000;
        Iterator it = hmup.entrySet().iterator();
        while (it.hasNext())
        {
            Map.Entry pair = (Map.Entry)it.next();
            int key=Integer.parseInt(pair.getKey().toString());
            int val=Integer.parseInt(pair.getValue().toString());
            if((val+hmdown.getOrDefault(key,0))*2>=n)
            {
                int need=0;
                if(n%2==0)need=n/2;
                else need=n/2+1;
                ans=Math.min(ans,need-val);
            }
        }
        it = hmdown.entrySet().iterator();
        while (it.hasNext())
        {
            Map.Entry pair = (Map.Entry)it.next();
            int key=Integer.parseInt(pair.getKey().toString());
            int val=Integer.parseInt(pair.getValue().toString());
            if(val*2>=n)
            {
                int need=0;
                if(n%2==0)need=n/2;
                else need=n/2+1;
                ans=Math.min(ans,need);
            }
        }
        ans=Math.max(ans,0);
        out.println(ans==2000000000?-1:ans);
        out.flush();
    }
}


import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
    static class Reader
    {
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;}
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];}
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;}
        public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();}
        public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;}
        public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;}
        public double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; }
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; }
        public int[] arr(int n){int[] ret = new int[n];for (int i = 0; i < n; i++) {ret[i] = i();}return ret;}
    }

    ///////////////////////////////////////////////////////////////////////////////////////////
    //    RRRRRRRRR            AAA             HHH     HHH     IIIIIIIIIIIII   LLL           //
    //    RR    RRR           AAAAA            HHH     HHH      IIIIIIIIIII    LLL           //
    //    RR   RRR           AAAAAAA           HHH     HHH          III        LLL           //
    //    RR  RRR           AAA   AAA          HHHHHHHHHHH          III        LLL           //
    //    RRRRRR           AAA     AAA         HHHHHHHHHHH          III        LLL           //
    //    RR  RRR         AAAAAAAAAAAAA        HHH     HHH          III        LLL           //
    //    RR    RRR      AAA         AAA       HHH     HHH      IIIIIIIIIII    LLLLLLLLLLLL  //
    //    RR     RRR    AAA           AAA      HHH     HHH     IIIIIIIIIIIII   LLLLLLLLLLLL  //
    ///////////////////////////////////////////////////////////////////////////////////////////

    public static void main(String[] args)throws IOException
    {
        PrintWriter out= new PrintWriter(System.out);
        Reader sc=new Reader();
        int n=sc.i();
        HashMap<Integer,Integer> hmup=new HashMap<>();
        HashMap<Integer,Integer> hmdown=new HashMap<>();
        for(int i=0;i<n;i++)
        {
            int a=sc.i();
            int b=sc.i();
            hmup.put(a,hmup.getOrDefault(a,0)+1);
            if(a!=b)
            hmdown.put(b,hmup.getOrDefault(b,0)+1);
        }
        int ans=2000000000;
        Iterator it = hmup.entrySet().iterator();
        while (it.hasNext())
        {
            Map.Entry pair = (Map.Entry)it.next();
            int key=Integer.parseInt(pair.getKey().toString());
            int val=Integer.parseInt(pair.getValue().toString());
            if((val+hmdown.getOrDefault(key,0))*2>=n)
            {
                int need=0;
                if(n%2==0)need=n/2;
                else need=n/2+1;
                ans=Math.min(ans,need-val);
            }
        }
        ans=Math.max(ans,0);
        out.println(ans==2000000000?-1:ans);
        out.flush();
    }
}


import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
    static class Reader
    {
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;}
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];}
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;}
        public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();}
        public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;}
        public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;}
        public double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; }
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; }
        public int[] arr(int n){int[] ret = new int[n];for (int i = 0; i < n; i++) {ret[i] = i();}return ret;}
    }

    ///////////////////////////////////////////////////////////////////////////////////////////
    //    RRRRRRRRR            AAA             HHH     HHH     IIIIIIIIIIIII   LLL           //
    //    RR    RRR           AAAAA            HHH     HHH      IIIIIIIIIII    LLL           //
    //    RR   RRR           AAAAAAA           HHH     HHH          III        LLL           //
    //    RR  RRR           AAA   AAA          HHHHHHHHHHH          III        LLL           //
    //    RRRRRR           AAA     AAA         HHHHHHHHHHH          III        LLL           //
    //    RR  RRR         AAAAAAAAAAAAA        HHH     HHH          III        LLL           //
    //    RR    RRR      AAA         AAA       HHH     HHH      IIIIIIIIIII    LLLLLLLLLLLL  //
    //    RR     RRR    AAA           AAA      HHH     HHH     IIIIIIIIIIIII   LLLLLLLLLLLL  //
    ///////////////////////////////////////////////////////////////////////////////////////////

    public static void main(String[] args)throws IOException
    {
        PrintWriter out= new PrintWriter(System.out);
        Reader sc=new Reader();
        int n=sc.i();
        HashMap<Integer,Integer> hmup=new HashMap<>();
        HashMap<Integer,Integer> hmdown=new HashMap<>();
        for(int i=0;i<n;i++)
        {
            int a=sc.i();
            int b=sc.i();
            hmup.put(a,hmup.getOrDefault(a,0)+1);
            if(a!=b)
            hmdown.put(b,hmup.getOrDefault(b,0)+1);
        }
        int ans=2000000000;
        Iterator it = hmup.entrySet().iterator();
        while (it.hasNext())
        {
            Map.Entry pair = (Map.Entry)it.next();
            int key=Integer.parseInt(pair.getKey().toString());
            int val=Integer.parseInt(pair.getValue().toString());
            if((val+hmdown.getOrDefault(key,0))*2>=n)
            {
                int need=0;
                if(n%2==0)need=n/2;
                else need=n/2+1;
                ans=Math.min(ans,need-val);
            }
        }
        out.println(ans==2000000000?-1:ans);
        out.flush();
    }
}


import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
    static class Reader
    {
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;}
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];}
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;}
        public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();}
        public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;}
        public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;}
        public double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; }
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; }
        public int[] arr(int n){int[] ret = new int[n];for (int i = 0; i < n; i++) {ret[i] = i();}return ret;}
    }

    ///////////////////////////////////////////////////////////////////////////////////////////
    //    RRRRRRRRR            AAA             HHH     HHH     IIIIIIIIIIIII   LLL           //
    //    RR    RRR           AAAAA            HHH     HHH      IIIIIIIIIII    LLL           //
    //    RR   RRR           AAAAAAA           HHH     HHH          III        LLL           //
    //    RR  RRR           AAA   AAA          HHHHHHHHHHH          III        LLL           //
    //    RRRRRR           AAA     AAA         HHHHHHHHHHH          III        LLL           //
    //    RR  RRR         AAAAAAAAAAAAA        HHH     HHH          III        LLL           //
    //    RR    RRR      AAA         AAA       HHH     HHH      IIIIIIIIIII    LLLLLLLLLLLL  //
    //    RR     RRR    AAA           AAA      HHH     HHH     IIIIIIIIIIIII   LLLLLLLLLLLL  //
    ///////////////////////////////////////////////////////////////////////////////////////////

    public static void main(String[] args)throws IOException
    {
        PrintWriter out= new PrintWriter(System.out);
        Reader sc=new Reader();
        int n=sc.i();
        HashMap<Integer,Integer> hmup=new HashMap<>();
        HashMap<Integer,Integer> hmdown=new HashMap<>();
        for(int i=0;i<n;i++)
        {
            int a=sc.i();
            int b=sc.i();
            hmup.put(a,hmup.getOrDefault(a,0)+1);
            if(a!=b)
            hmdown.put(b,hmdown.getOrDefault(b,0)+1);
        }
        int ans=2000000000;
        Iterator it = hmup.entrySet().iterator();
        while (it.hasNext())
        {
            Map.Entry pair = (Map.Entry)it.next();
            int key=Integer.parseInt(pair.getKey().toString());
            int val=Integer.parseInt(pair.getValue().toString());
            if((val+hmdown.getOrDefault(key,0))*2>=n)
            {
                int need=0;
                if(n%2==0)need=n/2;
                else need=n/2+1;
                ans=Math.min(ans,need-val);
            }
        }
        ans=Math.max(ans,0);
        out.println(ans==2000000000?-1:ans);
        out.flush();
    }
}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class LittleElephantandCards {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		HashSet<Integer> set = new HashSet<>();
		HashMap<Integer, Integer> mapF = new HashMap<>();
		HashMap<Integer, Integer> mapB = new HashMap<>();
		ArrayList<Point> a = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			int f = sc.nextInt();
			int b = sc.nextInt();

			set.add(f);
			set.add(b);

			if(!mapF.containsKey(f))
				mapF.put(f, 0);

			if(!mapF.containsKey(b))
				mapF.put(b, 0);

			if(!mapB.containsKey(b))
				mapB.put(b, 0);

			if(!mapB.containsKey(f))
				mapB.put(f, 0);

			mapF.put(f, mapF.get(f) + 1);

			if(f != b){
				mapB.put(b, mapB.get(b) + 1);
			}
		}

		for(Integer x : set){
			a.add(new Point(mapF.get(x), mapB.get(x)));
		}

		Collections.sort(a, new Comparator<Point>() {

			@Override
			public int compare(Point o1, Point o2) {
				return o2.x - o1.x;
			}
		});

		for (int i = 0; i < a.size(); i++) {
			if(a.get(i).x >= (n + 1) / 2){
				System.out.println(0);
				return;
			}

			if(a.get(i).x + a.get(i).y >= (n + 1) / 2){
				System.out.println((n + 1) / 2 - a.get(i).x);
				return;
			}
		}

		System.out.println(-1);
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

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

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

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

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}

		public boolean ready() throws IOException {return br.ready();}

	}

}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class LittleElephantandCards {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		HashSet<Integer> set = new HashSet<>();
		HashMap<Integer, Integer> mapF = new HashMap<>();
		HashMap<Integer, Integer> mapB = new HashMap<>();
		ArrayList<Point> a = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			int f = sc.nextInt();
			int b = sc.nextInt();

			set.add(f);
			set.add(b);

			if(!mapF.containsKey(f))
				mapF.put(f, 0);

			if(!mapF.containsKey(b))
				mapF.put(b, 0);

			if(!mapB.containsKey(b))
				mapB.put(b, 0);

			if(!mapB.containsKey(f))
				mapB.put(f, 0);

			mapF.put(f, mapF.get(f) + 1);

			if(f != b){
				mapB.put(b, mapB.get(b) + 1);
			}
		}

		for(Integer x : set){
			a.add(new Point(mapF.get(x), mapB.get(x)));
		}

		Collections.sort(a, new Comparator<Point>() {

			@Override
			public int compare(Point o1, Point o2) {
				return o2.x - o1.x;
			}
		});

		for (int i = 0; i < a.size(); i++) {
			if(a.get(i).x >= n / 2){
				System.out.println(0);
				return;
			}

			if(a.get(i).x + a.get(i).y >= n / 2){
				System.out.println((n + 1) / 2 - a.get(i).x);
				return;
			}
		}

		System.out.println(-1);
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

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

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

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

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}

		public boolean ready() throws IOException {return br.ready();}

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class D {

    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        TreeMap<Integer, Integer> f = new TreeMap<Integer, Integer>();
        TreeMap<Integer, Integer> b = new TreeMap<Integer, Integer>();
        TreeMap<Integer, Integer> colors = new TreeMap<Integer, Integer>();
        int n = in.nextInt();
        int fr, ba;
        int x = n / 2 + n % 2;
        for (int i = 0; i < n; i++) {
            fr = in.nextInt();
            ba = in.nextInt();
            colors.put(fr, 0);
            colors.put(ba, 0);
            if (fr != ba) {
                if (b.containsKey(ba)) {
                    b.put(ba, b.get(ba) + 1);
                } else {
                    b.put(ba, 1);
                }
            }
            if (f.containsKey(fr)) {
                f.put(fr, f.get(fr) + 1);
            } else {
                f.put(fr, 1);
            }
        }
        int min = Integer.MAX_VALUE;
        int y;
        for (Entry<Integer, Integer> e : colors.entrySet()) {
            Integer cur = f.get(e.getKey());
            if (cur == null)
                cur = 0;
            y = x - cur;
            if (y <= 0) {
                System.out.println(0);
                return;
            }
            if (b.containsKey(e.getKey())) {
                if (y <= b.get(e.getKey())) {
                    min = Math.min(min, y);
                }
            }
        }
        if (min == Integer.MAX_VALUE)
            min = -1;
        System.out.println(min);
    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer st;

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

        public String next() throws IOException {
            while (!st.hasMoreElements())
                st = new StringTokenizer(in.readLine());
            return st.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.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class D {

    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        TreeMap<Integer, Integer> f = new TreeMap<Integer, Integer>();
        TreeMap<Integer, Integer> b = new TreeMap<Integer, Integer>();
        int n = in.nextInt();
        int fr, ba;
        int x = n / 2 + n % 2;
        for (int i = 0; i < n; i++) {
            fr = in.nextInt();
            ba = in.nextInt();
            if (fr != ba) {
                if (b.containsKey(ba)) {
                    b.put(ba, b.get(ba) + 1);
                } else {
                    b.put(ba, 1);
                }
            }
            if (f.containsKey(fr)) {
                f.put(fr, f.get(fr) + 1);
            } else {
                f.put(fr, 1);
            }
        }
        int min = Integer.MAX_VALUE;
        int cur, y;
        for (Entry<Integer, Integer> e : f.entrySet()) {
            cur = e.getValue();
            y = x - cur;
            if (y <= 0) {
                System.out.println(0);
                return;
            }
            if (b.containsKey(e.getKey())) {
                if (y <= b.get(e.getKey())) {
                    min = Math.min(min, y);
                }
            }
        }
        if (min == Integer.MAX_VALUE)
            min = -1;
        System.out.println(min);
    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer st;

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

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

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

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


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

public class TaskD {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskD task = new TaskD();
        task.read();
        task.write();
    }

    int n;
    int k;
    Map<Integer, int[]> map = new HashMap<Integer, int[]>();
    int res = -1;

    public void read() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = n / 2;
        if (2 * k < n) {
            k++;
        }
        int x, y;
        for (int i = 0; i < n; i++) {
            x = in.nextInt();
            y = in.nextInt();
            if (!map.containsKey(x)) {
                map.put(x, new int[] { 0, 0 });
            }
            int[] ar = map.get(x);
            ar[0]++;
            if (x != y) {
                if (!map.containsKey(y)) {
                    map.put(y, new int[] { 0, 0 });
                }
                ar = map.get(y);
                ar[1]++;
            }
            if (ar[0] + ar[1] >= k) {
                int out = -1;
                if (k <= ar[0]) {
                    out = 0;
                } else {
                    out = k - ar[0];
                }
                if (res == -1 || out < res) {
                    res = out;
                }
            }
        }
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        out.println(res);
        out.flush();
        out.close();
    }
}


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

public class TaskD {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskD task = new TaskD();
        task.read();
        task.write();
    }

    int n;
    int k;
    int a[][] = new int[2][100010];
    Map<Integer, int[]> map = new HashMap<Integer, int[]>();
    int res = -1;

    public void read() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = n / 2;
        if (2 * k < n) {
            k++;
        }
        int x, y;
        for (int i = 0; i < n; i++) {
            x = in.nextInt();
            y = in.nextInt();
            a[0][i] = x;
            a[1][i] = y;
            if (!map.containsKey(x)) {
                map.put(x, new int[] { 0, 0 });
            }
            int[] ar = map.get(x);
            ar[0]++;
            if (ar[0] >= k) {
                res = 0;
            }
            if (!map.containsKey(y)) {
                map.put(y, new int[] { 0, 0 });
            }
        }
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        int ar[] = null;
        if (res == 0){
            out.println(0);
        }else{
        for (int i = 0; i < n; i++){
            int y = a[1][i];
            int x = a[0][i];
            if (x != y){
                ar = map.get(y);
                ar[0]++;
                ar[1]++;
                 if (ar[0] == k){
                if (res == -1 || res > ar[1]){
                    res = ar[1];
                }
            }
            }

        }
        out.println(res);
        }

        out.flush();
        out.close();
    }
}


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

public class TaskD {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskD task = new TaskD();
        task.read();
        task.write();
    }

    int n;
    int k;
    int a[][] = new int[2][100010];
    Map<Integer, int[]> map = new HashMap<Integer, int[]>();
    int res = -1;

    public void read() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = n / 2;
        if (2 * k < n) {
            k++;
        }
        int x, y;
        for (int i = 0; i < n; i++) {
            x = in.nextInt();
            y = in.nextInt();
            a[0][i] = x;
            a[1][i] = y;
            if (!map.containsKey(x)) {
                map.put(x, new int[] { 0, 0 });
            }
            int[] ar = map.get(x);
            ar[0]++;
            if (ar[0] >= k) {
                res = 0;
            }
            if (!map.containsKey(y)) {
                map.put(y, new int[] { 0, 0 });
            }
        }
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        if (res == 0){
            out.println(0);
        }else{
        for (int i = 0; i < n; i++){
            int y = a[1][i];
            int x = a[0][i];
            int ar[] = map.get(y);
            if (x != y){
                ar[0]++;
                ar[1]++;
            }
            if (ar[0] >= k){
                if (res == -1 || res < ar[1]){
                    res = ar[1];
                }
            }
        }
        out.println(res);
        }

        out.flush();
        out.close();
    }
}


import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class TaskD {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskD task = new TaskD();
        task.read();
        task.write();
    }

    int n;
    int k;
    Map<Integer, Integer> map = new HashMap<Integer, Integer>(100000);
    Map<Integer, Integer> map1 = new HashMap<Integer, Integer>(100000);
    int res = -1;

    public void read() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = n / 2;
        if (2 * k < n) {
            k++;
        }
        int x, y;
        int first, second;
        int first1, second1;
        for (int i = 0; i < n; i++) {
            x = in.nextInt();
            y = in.nextInt();
            if (!map.containsKey(x)) {
                map.put(x, 0);
                map1.put(x, 0);
            }
            first = 1 + map.get(x);
            map.put(x, first);
            second = map1.get(x);
            if (x != y) {
                if (!map.containsKey(y)) {
                    map.put(y, 0);
                    map1.put(y, 0);
                }
                second1 = 1 + map1.get(y);
                map1.put(y, second1);
                first1 = map.get(y);
                if (first1 + second1 >= k) {
                    int out = -1;
                    if (k <= first1) {
                        out = 0;
                    } else {
                        out = k - first1;
                    }
                    if (res == -1 || out < res) {
                        res = out;
                    }
                }
            }
            if (first + second >= k) {
                int out = -1;
                if (k <= first) {
                    out = 0;
                } else {
                    out = k - first;
                }
                if (res == -1 || out < res) {
                    res = out;
                }
            }

        }
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        out.println(res);
        out.flush();
        out.close();
    }
}


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

public class TaskD {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskD task = new TaskD();
        task.read();
        task.write();
    }

    int n;
    int k;
    Map<Integer, int[]> map = new HashMap<Integer, int[]>();
    int res = -1;

    public void read() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = n / 2;
        if (2 * k < n) {
            k++;
        }
        int x, y;
        for (int i = 0; i < n; i++) {
            x = in.nextInt();
            y = in.nextInt();
            if (!map.containsKey(x)) {
                map.put(x, new int[] { 0, 0 });
            }
            int[] ar = map.get(x);
            ar[0]++;
            if (!map.containsKey(y)) {
                map.put(y, new int[] { 0, 0 });
            }
            ar = map.get(y);
            ar[1]++;
            if (ar[0]+ ar[1] >= k) {
                int out;
                if (k <= ar[0]){
                    out = 0;
                }else{
                    out = k - ar[0];
                }
                if (res == -1 || out < res){
                    res = out;
                }
            }
        }
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        out.println(res);
        out.flush();
        out.close();
    }
}


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

public class TaskD {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskD task = new TaskD();
        task.read();
        task.write();
    }

    int n;
    int k;
    int a[][] = new int[2][100010];
    Map<Integer, int[]> map = new HashMap<Integer, int[]>();
    int res = -1;

    public void read() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = n / 2;
        if (2 * k < n) {
            k++;
        }
        int x, y;
        for (int i = 0; i < n; i++) {
            x = in.nextInt();
            y = in.nextInt();
            a[0][i] = x;
            a[1][i] = y;
            if (!map.containsKey(x)) {
                map.put(x, new int[] { 0, 0 });
            }
            int[] ar = map.get(x);
            ar[0]++;
            if (ar[0] >= k) {
                res = 0;
            }
            if (!map.containsKey(y)) {
                map.put(y, new int[] { 0, 0 });
            }
        }
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        if (res == 0){
            out.println(0);
        }else{
        for (int i = 0; i < n; i++){
            int y = a[1][i];
            int x = a[0][i];
            int ar[] = map.get(y);
            if (x != y){
                ar[0]++;
                ar[1]++;
            }
            if (ar[0] >= k){
                if (res == -1 || res > ar[1]){
                    res = ar[1];
                }
            }
        }
        out.println(res);
        }

        out.flush();
        out.close();
    }
}


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

public class TaskD {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskD task = new TaskD();
        task.read();
        task.write();
    }

    int n;
    int k;
    int a[][] = new int[2][100010];
    Map<Integer, int[]> map = new HashMap<Integer, int[]>();
    int res = -1;

    public void read() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = n / 2;
        if (2 * k < n) {
            k++;
        }
        int x, y;
        for (int i = 0; i < n; i++) {
            x = in.nextInt();
            y = in.nextInt();
            a[0][i] = x;
            a[1][i] = y;
            if (!map.containsKey(x)) {
                map.put(x, new int[] { 0, 0 });
            }
            int[] ar = map.get(x);
            ar[0]++;
            if (ar[0] >= k) {
                res = 0;
            }
            if (!map.containsKey(y)) {
                map.put(y, new int[] { 0, 0 });
            }
        }
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        if (res == 0){
            out.println(0);
        }else{
        for (int i = 0; i < n; i++){
            int y = a[1][i];
            int x = a[0][i];
            int ar[] = map.get(y);
            if (x != y){
                ar[0]++;
                ar[1]++;
            }
            if (ar[0] >= k){
                if (res == -1 || res > ar[1]){
                    res = ar[1];
                }
                break;
            }
        }
        out.println(res);
        }

        out.flush();
        out.close();
    }
}


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

public class TaskD {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskD task = new TaskD();
        task.read();
        task.write();
    }

    int n;
    int k;
    int a[][] = new int[2][100010];
    Map<Integer, int[]> map = new HashMap<Integer, int[]>();
    int res = -1;

    public void read() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = n / 2;
        if (2 * k < n) {
            k++;
        }
        int x, y;
        for (int i = 0; i < n; i++) {
            x = in.nextInt();
            y = in.nextInt();
            a[0][i] = x;
            a[1][i] = y;
            if (!map.containsKey(x)) {
                map.put(x, new int[] { 0, 0 });
            }
            int[] ar = map.get(x);
            ar[0]++;
            if (ar[0] >= k) {
                res = 0;
            }
            if (!map.containsKey(y)) {
                map.put(y, new int[] { 0, 0 });
            }
        }
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        int ar[];
        if (res == 0){
            out.println(0);
        }else{
        for (int i = 0; i < n; i++){
            int y = a[1][i];
            int x = a[0][i];
            if (x != y){
                ar = map.get(y);
                ar[0]++;
                ar[1]++;
            }
            if (ar[0] == k){
                if (res == -1 || res > ar[1]){
                    res = ar[1];
                }
            }
        }
        out.println(res);
        }

        out.flush();
        out.close();
    }
}


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

public class TaskD {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskD task = new TaskD();
        task.read();
        task.write();
    }

    int n;
    int k;
    int a[][] = new int[2][100010];
    Map<Integer, int[]> map = new HashMap<Integer, int[]>();
    int res = -1;

    public void read() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = n / 2;
        if (2 * k < n) {
            k++;
        }
        int x, y;
        for (int i = 0; i < n; i++) {
            x = in.nextInt();
            y = in.nextInt();
            a[0][i] = x;
            a[1][i] = y;
            if (!map.containsKey(x)) {
                map.put(x, new int[] { 0, 0 });
            }
            int[] ar = map.get(x);
            ar[0]++;
            if (ar[0] >= k) {
                res = 0;
            }
            if (!map.containsKey(y)) {
                map.put(y, new int[] { 0, 0 });
            }
        }
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        if (res == 0){
            out.println(0);
        }else{
        for (int i = 0; i < n; i++){
            int y = a[1][i];
            int ar[] = map.get(y);
            ar[0]++;
            ar[1]++;
            if (ar[0] >= k){
                if (res == -1 || res < ar[1]){
                    res = ar[1];
                }
                break;
            }
        }
        out.println(res);
        }

        out.flush();
        out.close();
    }
}


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

public class TaskD {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskD task = new TaskD();
        task.read();
        task.write();
    }

    int n;
    int k;
    Map<Integer, int[]> map = new HashMap<Integer, int[]>();
    int res = -1;

    public void read() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = n / 2;
        if (2 * k < n) {
            k++;
        }
        int x, y;
        for (int i = 0; i < n; i++) {
            x = in.nextInt();
            y = in.nextInt();
            if (!map.containsKey(x)) {
                map.put(x, new int[] { 0, 0 });
            }
            int[] ar = map.get(x);
            ar[0]++;
            if (x != y) {
                if (!map.containsKey(y)) {
                    map.put(y, new int[] { 0, 0 });
                }
                int[] br = map.get(y);
                br[1]++;
                if (br[0] + br[1] >= k) {
                    int out = -1;
                    if (k <= br[0]) {
                        out = 0;
                    } else {
                        out = k - br[0];
                    }
                    if (res == -1 || out < res) {
                        res = out;
                    }
                }
            }
            if (ar[0] + ar[1] >= k) {
                int out = -1;
                if (k <= ar[0]) {
                    out = 0;
                } else {
                    out = k - ar[0];
                }
                if (res == -1 || out < res) {
                    res = out;
                }
            }

        }
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        out.println(res);
        out.flush();
        out.close();
    }
}


import java.io.PrintWriter;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class TaskD {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskD task = new TaskD();
        task.read();
        task.write();
    }

    int n;
    int k;
    Map<Integer, Integer> map = new TreeMap<Integer, Integer>();
    Map<Integer, Integer> map1 = new TreeMap<Integer, Integer>();
    int res = -1;

    public void read() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = n / 2;
        if (2 * k < n) {
            k++;
        }
        int x, y;
        int first, second;
        int first1, second1;
        for (int i = 0; i < n; i++) {
            x = in.nextInt();
            y = in.nextInt();
            if (!map.containsKey(x)) {
                map.put(x, 0);
                map1.put(x, 0);
            }
            first = 1 + map.get(x);
            map.put(x, first);
            second = map1.get(x);
            if (x != y) {
                if (!map.containsKey(y)) {
                    map.put(y, 0);
                    map1.put(y, 0);
                }
                second1 = 1 + map1.get(y);
                map1.put(y, second1);
                first1 = map.get(y);
                if (first1 + second1 >= k) {
                    int out = -1;
                    if (k <= first1) {
                        out = 0;
                    } else {
                        out = k - first1;
                    }
                    if (res == -1 || out < res) {
                        res = out;
                    }
                }
            }
            if (first + second >= k) {
                int out = -1;
                if (k <= first) {
                    out = 0;
                } else {
                    out = k - first;
                }
                if (res == -1 || out < res) {
                    res = out;
                }
            }

        }
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        out.println(res);
        out.flush();
        out.close();
    }
}


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

public class TaskD {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskD task = new TaskD();
        task.read();
        task.write();
    }

    int n;
    int k;
    Map<Integer, Integer> map = new HashMap<Integer, Integer>();
    Map<Integer, Integer> map1 = new HashMap<Integer, Integer>();
    int res = -1;

    public void read() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = n / 2;
        if (2 * k < n) {
            k++;
        }
        int x, y;
        int first, second;
        int first1, second1;
        for (int i = 0; i < n; i++) {
            x = in.nextInt();
            y = in.nextInt();
            if (!map.containsKey(x)) {
                map.put(x, 0);
                map1.put(x, 0);
            }
            first = 1 + map.get(x);
            map.put(x, first);
            second = map1.get(x);
            if (x != y) {
                if (!map.containsKey(y)) {
                    map.put(y, 0);
                    map1.put(y, 0);
                }
                second1 = 1 + map1.get(y);
                map1.put(y, second1);
                first1 = map.get(y);
                if (first1 + second1 >= k) {
                    int out = -1;
                    if (k <= first1) {
                        out = 0;
                    } else {
                        out = k - first1;
                    }
                    if (res == -1 || out < res) {
                        res = out;
                    }
                }
            }
            if (first + second >= k) {
                int out = -1;
                if (k <= first) {
                    out = 0;
                } else {
                    out = k - first;
                }
                if (res == -1 || out < res) {
                    res = out;
                }
            }

        }
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        out.println(res);
        out.flush();
        out.close();
    }
}


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

public class TaskD {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskD task = new TaskD();
        task.read();
        task.write();
    }

    int n;
    int k;
    int a[][] = new int[2][100010];
    Map<Integer, int[]> map = new HashMap<Integer, int[]>();
    int res = -1;

    public void read() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = n / 2;
        if (2 * k < n) {
            k++;
        }
        int x, y;
        for (int i = 0; i < n; i++) {
            x = in.nextInt();
            y = in.nextInt();
            a[0][i] = x;
            a[1][i] = y;
            if (!map.containsKey(x)) {
                map.put(x, new int[] { 0, 0 });
            }
            int[] ar = map.get(x);
            ar[0]++;
            if (ar[0] >= k) {
                res = 0;
            }
            if (!map.containsKey(y)) {
                map.put(y, new int[] { 0, 0 });
            }
        }
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        if (res == 0){
            out.println(0);
        }else{
        for (int i = 0; i < n; i++){
            int y = a[1][i];
            int x = a[0][i];
            int ar[] = map.get(y);
            if (x != y){
                ar[0]++;
                ar[1]++;
            }
            if (ar[0] >= k){
                if (res == -1 || res < ar[1]){
                    res = ar[1];
                }
                break;
            }
        }
        out.println(res);
        }

        out.flush();
        out.close();
    }
}


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

public class TaskD {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskD task = new TaskD();
        task.read();
        task.write();
    }

    int n;
    int k;
    Map<Integer, int[]> map = new HashMap<Integer, int[]>();
    int res = -1;

    public void read() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = n / 2;
        if (2 * k < n) {
            k++;
        }
        int x, y;
        for (int i = 0; i < n; i++) {
            x = in.nextInt();
            y = in.nextInt();
            if (!map.containsKey(x)) {
                map.put(x, new int[] { 0, 0 });
            }
            int[] ar = map.get(x);
            if (x != y) {
                ar[0]++;
                if (!map.containsKey(y)) {
                    map.put(y, new int[] { 0, 0 });
                }
                ar = map.get(y);
                ar[1]++;
            }
            if (ar[0] + ar[1] >= k) {
                int out = -1;
                if (k <= ar[0]) {
                    out = 0;
                } else {
                    out = k - ar[0];
                }
                if (res == -1 || out < res) {
                    res = out;
                }
            }
        }
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        out.println(res);
        out.flush();
        out.close();
    }
}


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

public class TaskD {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskD task = new TaskD();
        task.read();
        task.write();
    }

    int n;
    int k;
    int a[][] = new int[2][100010];
    Map<Integer, int[]> map = new HashMap<Integer, int[]>();
    int res = -1;

    public void read() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = n / 2;
        if (2 * k < n) {
            k++;
        }
        int x, y;
        for (int i = 0; i < n; i++) {
            x = in.nextInt();
            y = in.nextInt();
            a[0][i] = x;
            a[1][i] = y;
            if (!map.containsKey(x)) {
                map.put(x, new int[] { 0, 0 });
            }
            int[] ar = map.get(x);
            ar[0]++;
            if (ar[0] >= k) {
                res = 0;
            }
            if (!map.containsKey(y)) {
                map.put(y, new int[] { 0, 0 });
            }
        }
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        if (res == 0){
            out.println(0);
        }else{
        for (int i = 0; i < n; i++){
            int y = a[1][i];
            int ar[] = map.get(y);
            ar[0]++;
            ar[1]++;
            if (ar[0] >= k){
                res = ar[1];
                break;
            }
        }
        out.println(res);
        }

        out.flush();
        out.close();
    }
}


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

public class TaskD {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskD task = new TaskD();
        task.read();
        task.write();
    }

    int n;
    int k;
    int a[][] = new int[2][100010];
    Map<Integer, int[]> map = new HashMap<Integer, int[]>();
    int res = -1;

    public void read() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = n / 2;
        if (2 * k < n) {
            k++;
        }
        int x, y;
        for (int i = 0; i < n; i++) {
            x = in.nextInt();
            y = in.nextInt();
            a[0][i] = x;
            a[1][i] = y;
            if (!map.containsKey(x)) {
                map.put(x, new int[] { 0, 0 });
            }
            int[] ar = map.get(x);
            ar[0]++;
            if (ar[0] >= k) {
                res = 0;
            }
            if (!map.containsKey(y)) {
                map.put(y, new int[] { 0, 0 });
            }
        }
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        int ar[];
        if (res == 0){
            out.println(0);
        }else{
        for (int i = 0; i < n; i++){
            int y = a[1][i];
            int x = a[0][i];
            if (x != y){
                ar = map.get(y)
                ar[0]++;
                ar[1]++;
            }
            if (ar[0] == k){
                if (res == -1 || res > ar[1]){
                    res = ar[1];
                }
            }
        }
        out.println(res);
        }

        out.flush();
        out.close();
    }
}


import java.util.Set;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;

import static java.lang.Math.*;

public class d implements Runnable {

    String input = "";
    String output = "";
    BufferedReader bf;
    FastScanner in;
    PrintWriter out;

    public void solve() throws Exception {
        int n = in.nextInt();
        int a[][] = new int[n + n][2];
        HashMap<Integer, Integer> hash = new HashMap<Integer, Integer>();
        int j = 0;
        for (int i = 0; i<n; i++){
            int a1 = in.nextInt();
            int b1 = in.nextInt();
            Object t = hash.get(a1);
            if (t != null){
                a[(Integer)t][0]++;
            }else{
                hash.put(a1, j);
                a[j][0] = 1;
                j++;
            }

            if (a1 == b1) continue;

            t = hash.get(b1);
            if (t != null ){
                a[(Integer)t][1]++;
            }else {
                hash.put(b1, j);
                a[j][1] = 1;
                j++;
            }
        }
        int min = (int)1e9;
        int mid = (n + 1) / 2;
        for (int i = 0; i<j; i++){
            if (a[i][0] >= mid){
                out.println(0);
                return;
            }else {
                if (a[i][0] + a[i][1] >= mid){
                    //out.println("this i = " + i + " " + a[i][0] + " " + a[i][1]+ " " + (a[i][0] + a[i][1]));
                    min = min(min, mid - a[i][0]);
                }
            }
        }

        if (min == (int)1e9)
            out.println(-1);
        else
            out.println(min);
    }

    @Override
    public void run() {
        try {
            if (input.equals("")) {
                bf = new BufferedReader(new InputStreamReader(System.in));
            } else {
                bf = new BufferedReader(new FileReader(input));
            }

            in = new FastScanner(bf);

            if (output.equals("")) {
                out = new PrintWriter(System.out);
            } else {
                out = new PrintWriter(new File(output));
            }

            solve();

            out.flush();

        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            out.close();
        }
    }

    public static void main(String[] args) {
        new Thread(null, new d(), "1", 1 << 23).start();
    }

    class FastScanner {

        BufferedReader bf;
        StringTokenizer st;

        public FastScanner(BufferedReader bf) {
            this.bf = bf;
        }

        public String next() throws Exception {

            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(bf.readLine());
            }

            return st.nextToken();
        }

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

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

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


//package Round_129;

import java.util.Set;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;

import static java.lang.Math.*;

public class d implements Runnable {

    String input = "";
    String output = "";
    BufferedReader bf;
    FastScanner in;
    PrintWriter out;

    public void solve() throws Exception {
        int n = in.nextInt();
        int a[][] = new int[n + n][2];
        HashMap<Integer, Integer> hash = new HashMap<Integer, Integer>();
        int j = 0;
        for (int i = 0; i<n; i++){
            int a1 = in.nextInt();
            int b1 = in.nextInt();
            if (hash.containsKey(a1)){
                int t = hash.get(a1);
                a[t][0]++;
            }else{
                hash.put(a1, j);
                a[j][0] = 1;
                j++;
            }

            if (a1 == b1) continue;

            if (hash.containsKey(b1)){
                int t = hash.get(b1);
                a[t][1]++;
            }else {
                hash.put(b1, j);
                a[j][1] = 1;
                j++;
            }
        }
        int min = (int)1e9;
        int mid = (n + 1) / 2;
        for (int i = 0; i<j; i++){
            if (a[i][0] >= mid){
                out.println(0);
                return;
            }else {
                if (a[i][0] + a[i][1] >= mid){
                    //out.println("this i = " + i + " " + a[i][0] + " " + a[i][1]+ " " + (a[i][0] + a[i][1]));
                    min = min(min, mid - a[i][0]);
                }
            }
        }

        if (min == (int)1e9)
            out.println(-1);
        else
            out.println(min);
    }

    @Override
    public void run() {
        try {
            if (input.equals("")) {
                bf = new BufferedReader(new InputStreamReader(System.in));
            } else {
                bf = new BufferedReader(new FileReader(input));
            }

            in = new FastScanner(bf);

            if (output.equals("")) {
                out = new PrintWriter(System.out);
            } else {
                out = new PrintWriter(new File(output));
            }

            solve();

            out.flush();

        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            out.close();
        }
    }

    public static void main(String[] args) {
        new Thread(null, new d(), "1", 1 << 23).start();
    }

    class FastScanner {

        BufferedReader bf;
        StringTokenizer st;

        public FastScanner(BufferedReader bf) {
            this.bf = bf;
        }

        public String next() throws Exception {

            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(bf.readLine());
            }

            return st.nextToken();
        }

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

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

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


//package Round_129;

import java.util.Set;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;

import static java.lang.Math.*;

public class d implements Runnable {

    String input = "";
    String output = "";
    BufferedReader bf;
    FastScanner in;
    PrintWriter out;

    public void solve() throws Exception {
        int n = in.nextInt();
        int a[][] = new int[n][2];
        HashMap<Integer, Integer> hash = new HashMap<Integer, Integer>();
        HashMap<Integer, Integer> hash2 = new HashMap<Integer, Integer>();
        for (int i = 0; i<n; i++){
            int a1 = in.nextInt();
            int b1 = in.nextInt();
            if (hash.containsKey(a1)){
                int t = hash.get(a1);
                a[t][0]++;
            }else {
                hash.put(a1, i);
                a[i][0]++;
            }
            if (hash2.containsKey(b1)){
                int t = hash2.get(b1);
                a[t][1]++;
            }else {
                hash2.put(b1, i);
                a[i][1]++;
            }
        }
        int min = (int)1e9;
        int mid = (n + 1) / 2;
        for (int i = 0; i<n; i++){
            if (a[i][0] > mid){
                out.println(0);
                return;
            }else {
                if (a[i][0] + a[i][1] >= mid){
                    min = min(min, mid - a[i][0]);
                }
            }
        }
        if (min == (int)1e9)
            out.println(-1);
        else
            out.println(min);
    }

    @Override
    public void run() {
        try {
            if (input.equals("")) {
                bf = new BufferedReader(new InputStreamReader(System.in));
            } else {
                bf = new BufferedReader(new FileReader(input));
            }

            in = new FastScanner(bf);

            if (output.equals("")) {
                out = new PrintWriter(System.out);
            } else {
                out = new PrintWriter(new File(output));
            }

            solve();

            out.flush();

        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            out.close();
        }
    }

    public static void main(String[] args) {
        new Thread(null, new d(), "1", 1 << 23).start();
    }

    class FastScanner {

        BufferedReader bf;
        StringTokenizer st;

        public FastScanner(BufferedReader bf) {
            this.bf = bf;
        }

        public String next() throws Exception {

            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(bf.readLine());
            }

            return st.nextToken();
        }

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

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

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


//package Round_129;

import java.util.Map;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

import java.util.TreeMap;
import static java.lang.Math.*;

public class d implements Runnable {

    String input = "";
    String output = "";
    BufferedReader bf;
    FastScanner in;
    PrintWriter out;

    public void solve() throws Exception {
        int n = in.nextInt();
        int a[][] = new int[n + n + 1][2];
        //HashMap<Integer, Integer> hash = new HashMap<Integer, Integer>();
        Map<Integer, Integer> hash = new TreeMap<Integer, Integer>();
        int j = 0;
        for (int i = 0; i<n; i++){
            int a1 = in.nextInt();
            int b1 = in.nextInt();
            int t = 0;
            if (hash.containsKey(a1)){
                t = hash.get(a1);
                a[t][0]++;
            }else{
                hash.put(a1, j);
                a[j][0] = 1;
                j++;
            }

            if (a1 == b1) continue;

            if (hash.containsKey(b1)){
                t = hash.get(b1);
                a[t][1]++;
            }else {
                hash.put(b1, j);
                a[j][1] = 1;
                j++;
            }
        }

        int min = (int)1e9;
        int mid = (n + 1) / 2;
        for (int i = 0; i<j; i++){
            if (a[i][0] >= mid){
                out.println(0);
                return;
            }else {
                if (a[i][0] + a[i][1] >= mid){
                    //out.println("this i = " + i + " " + a[i][0] + " " + a[i][1]+ " " + (a[i][0] + a[i][1]));
                    min = min(min, mid - a[i][0]);
                }
            }
        }

        if (min == (int)1e9)
            out.println(-1);
        else
            out.println(min);
    }

    @Override
    public void run() {
        try {
            if (input.equals("")) {
                bf = new BufferedReader(new InputStreamReader(System.in));
            } else {
                bf = new BufferedReader(new FileReader(input));
            }

            in = new FastScanner(bf);

            if (output.equals("")) {
                out = new PrintWriter(System.out);
            } else {
                out = new PrintWriter(new File(output));
            }

            solve();

            out.flush();

        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            out.close();
        }
    }

    public static void main(String[] args) {
        new Thread(null, new d(), "1", 1 << 23).start();
    }

    class FastScanner {

        BufferedReader bf;
        StringTokenizer st;

        public FastScanner(BufferedReader bf) {
            this.bf = bf;
        }

        public String next() throws Exception {

            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(bf.readLine());
            }

            return st.nextToken();
        }

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

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

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


//package Round_129;

import java.util.Set;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;

import static java.lang.Math.*;

public class d implements Runnable {

    String input = "";
    String output = "";
    BufferedReader bf;
    FastScanner in;
    PrintWriter out;

    public void solve() throws Exception {
        int n = in.nextInt();
        int a[][] = new int[n + n + 1][2];
        HashMap<Integer, Integer> hash = new HashMap<Integer, Integer>();
        int j = 0;
        for (int i = 0; i<n; i++){
            int a1 = in.nextInt();
            int b1 = in.nextInt();
            Object t = hash.get(a1);
            if (t != null){
                a[(Integer)t][0]++;
            }else{
                hash.put(a1, j);
                a[j][0] = 1;
                j++;
            }

            if (a1 == b1) continue;

            t = hash.get(b1);
            if (t != null ){
                a[(Integer)t][1]++;
            }else {
                hash.put(b1, j);
                a[j][1] = 1;
                j++;
            }
        }
        int min = (int)1e9;
        int mid = (n + 1) / 2;
        for (int i = 0; i<j; i++){
            if (a[i][0] >= mid){
                out.println(0);
                return;
            }else {
                if (a[i][0] + a[i][1] >= mid){
                    //out.println("this i = " + i + " " + a[i][0] + " " + a[i][1]+ " " + (a[i][0] + a[i][1]));
                    min = min(min, mid - a[i][0]);
                }
            }
        }

        if (min == (int)1e9)
            out.println(-1);
        else
            out.println(min);
    }

    @Override
    public void run() {
        try {
            if (input.equals("")) {
                bf = new BufferedReader(new InputStreamReader(System.in));
            } else {
                bf = new BufferedReader(new FileReader(input));
            }

            in = new FastScanner(bf);

            if (output.equals("")) {
                out = new PrintWriter(System.out);
            } else {
                out = new PrintWriter(new File(output));
            }

            solve();

            out.flush();

        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            out.close();
        }
    }

    public static void main(String[] args) {
        new Thread(null, new d(), "1", 1 << 23).start();
    }

    class FastScanner {

        BufferedReader bf;
        StringTokenizer st;

        public FastScanner(BufferedReader bf) {
            this.bf = bf;
        }

        public String next() throws Exception {

            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(bf.readLine());
            }

            return st.nextToken();
        }

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

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

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


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

public class P205D {

  public PrintWriter run() {
    TreeMap<Integer, Integer> card = new TreeMap<Integer, Integer>();
    TreeMap<Integer, Integer> face = new TreeMap<Integer, Integer>();
    int n = sc.nextInt();

    for (int i = 0; i < n; i++) {
      int nface = sc.nextInt();
      int nback = sc.nextInt();

      Integer count = card.get(nface);
      card.put(nface, (count != null) ? (count + 1) : 1);

      if (nback != nface) {
        count = card.get(nback);
        card.put(nback, (count != null) ? (count + 1) : 1);
      }

      count = face.get(nface);
      face.put(nface, (count != null) ? (count + 1) : 1);
    }

    int n_2 = (n + 1) / 2;

    int maxVal = -1;
    Iterator<Integer> iter = card.keySet().iterator();
    while (iter.hasNext()) {
      int tKey = iter.next();
      if (card.get(tKey) >= n_2) {
        Integer tVal = face.get(tKey);
        tVal = (tVal != null) ? tVal : 0;
        maxVal = (tVal > maxVal) ? tVal : maxVal;
      }
    }

    if (maxVal < 0) {
      pw.println(-1);
    } else if (maxVal >= n_2) {
      pw.println(0);
    } else {
      pw.println(n_2 - maxVal);
    }

    return pw;
  }

  private Scanner sc = new Scanner(new BufferedInputStream(System.in));
  private PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));

  public static void main(String[] args) throws Exception {
    new P205D().run().close();
  }
}


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

public class P205D {

  public PrintWriter run() {
    TreeMap<Integer, Integer> card = new TreeMap<Integer, Integer>();
    TreeMap<Integer, Integer> face = new TreeMap<Integer, Integer>();
    int n = sc.nextInt();

    for (int i = 0; i < n; i++) {
      int nface = sc.nextInt();
      int nback = sc.nextInt();

      Integer count = card.get(nface);
      card.put(nface, (count != null) ? (count + 1) : 1);

      if (nback != nface) {
        count = card.get(nback);
        card.put(nback, (count != null) ? (count + 1) : 1);
      }

      count = face.get(nface);
      face.put(nface, (count != null) ? (count + 1) : 1);
    }

    int n_2 = (n + 1) / 2;

    int maxVal = -1;
    Iterator<Integer> iter = card.keySet().iterator();
    while (iter.hasNext()) {
      int tKey = iter.next();
      if (card.get(tKey) >= n_2) {
        Integer tVal = face.get(tKey);
        tVal = (tVal != null) ? tVal : -1;
        maxVal = (tVal > maxVal) ? tVal : maxVal;
      }
    }

    if (maxVal < 0) {
      pw.println(-1);
    } else if (maxVal >= n_2) {
      pw.println(0);
    } else {
      pw.println(n_2 - maxVal);
    }

    return pw;
  }

  private Scanner sc = new Scanner(new BufferedInputStream(System.in));
  private PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));

  public static void main(String[] args) throws Exception {
    new P205D().run().close();
  }
}


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

public class P205D {

  public PrintWriter run() {
    TreeMap<Integer, Integer> card = new TreeMap<Integer, Integer>();
    TreeMap<Integer, Integer> face = new TreeMap<Integer, Integer>();
    int n = sc.nextInt();

    for (int i = 0; i < n; i++) {
      int nface = sc.nextInt();
      int nback = sc.nextInt();

      Integer c = card.get(nface);
      c = (c != null) ? (c + 1) : new Integer(1);
      card.put(nface, c);
      face.put(nface, c);

      if (nback != nface) {
        c = card.get(nface);
        card.put(nback, ((c != null) ? (c + 1) : new Integer(1)));
      }
    }

    int n_2 = (n + 1) / 2;

    int maxVal = -1;
    Iterator<Integer> iter = card.keySet().iterator();
    while (iter.hasNext()) {
      int tKey = iter.next();
      if (card.get(tKey) >= n_2) {
        Integer tVal = face.get(tKey);
        tVal = (tVal != null) ? tVal : 0;
        maxVal = (tVal > maxVal) ? tVal : maxVal;
      }
    }

    if (maxVal < 0) {
      pw.println(-1);
    } else if (maxVal >= n_2) {
      pw.println(0);
    } else {
      pw.println(n_2 - maxVal);
    }

    return pw;
  }

  private Scanner sc = new Scanner(new BufferedInputStream(System.in));
  private PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));

  public static void main(String[] args) throws Exception {
    new P205D().run().close();
  }
}


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

public class P205D {

  public PrintWriter run() {
    TreeMap<Integer, Integer> card = new TreeMap<Integer, Integer>();
    TreeMap<Integer, Integer> face = new TreeMap<Integer, Integer>();
    int n = sc.nextInt();

    for (int i = 0; i < n; i++) {
      int nface = sc.nextInt();
      int nback = sc.nextInt();

      Integer c = card.get(nface);
      c = (c != null) ? (c + 1) : new Integer(1);
      card.put(nface, c);
      face.put(nface, c);

      if (nback != nface) {
        c = card.get(nface);
        card.put(nback, ((c != null) ? (c + 1) : new Integer(1)));
      }
    }

    int n_2 = (n + 1) / 2;

    int maxVal = -1;
    Iterator<Integer> iter = card.keySet().iterator();
    while (iter.hasNext()) {
      int tKey = iter.next();
      if (card.get(tKey) >= n_2) {
        Integer tVal = face.get(tKey);
        tVal = (tVal != null) ? tVal : -1;
        maxVal = (tVal > maxVal) ? tVal : maxVal;
      }
    }

    if (maxVal < 0) {
      pw.println(-1);
    } else if (maxVal >= n_2) {
      pw.println(0);
    } else {
      pw.println(n_2 - maxVal);
    }

    return pw;
  }

  private Scanner sc = new Scanner(new BufferedInputStream(System.in));
  private PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));

  public static void main(String[] args) throws Exception {
    new P205D().run().close();
  }
}


import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
public class cf204b {
  public static void main(String[] args){
    InputReader in = new InputReader(System.in);
    int n = in.readInt();
    Cluster front = new Cluster(), back = new Cluster(), both = new Cluster();
    Set<Integer> all = new TreeSet<Integer>();
    for(int i=0; i<n; i++) {
      int a = in.readInt();
      int b = in.readInt();
      front.add(a);
      back.add(b);
      if(a==b) both.add(a);
      all.add(a);
      all.add(b);
    }
    int oo = 987654321;
    int ans = oo;
    int needed = (n+1)/2;
    for(int x : all) {
      int a = front.get(x);
      int b = back.get(x);
      int c = both.get(x);
      int total = a+b-c;
      if(total < needed) continue;
      int left = needed;
      left -= a;
      if(left < 0) left = 0;
      ans = Math.min(ans,left);
    }
    if(ans >= oo) ans = -1;
    System.out.println(ans);
  }
  static class Cluster {
    Map<Integer,Integer> map = new TreeMap<Integer,Integer>();
    void add(int x) {
      if(!map.containsKey(x)) map.put(x,1);
      else map.put(x,map.get(x)+1);
    }
    int get(int x) {
      if(!map.containsKey(x)) return 0;
      return map.get(x);
    }
  }
  static class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (numChars == -1)
        throw new InputMismatchException();
      if (curChar >= numChars) {
        curChar = 0;
        try {
          numChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (numChars <= 0)
          return -1;
      }
      return buf[curChar++];
    }

    public int readInt() {
      int c = read();
      while (isSpaceChar(c))
        c = read();
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9')
          throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public String readString() {
      int c = read();
      while (isSpaceChar(c))
        c = read();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = read();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null)
        return filter.isSpaceChar(c);
      return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Solver {

    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws NumberFormatException, IOException {
        Solver solver = new Solver();
        solver.open();
        long time = System.currentTimeMillis();
        solver.solve();
        if (!"true".equals(System.getProperty("ONLINE_JUDGE"))) {
            System.out.println("Spent time: " + (System.currentTimeMillis() - time));
        }
        solver.close();
    }

    public void open() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

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

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

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

    public double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }

    public void solve() throws NumberFormatException, IOException {
        int n = nextInt();

        Map<Integer, Integer> front = new TreeMap<Integer, Integer>();
        Map<Integer, Integer> back = new TreeMap<Integer, Integer>();

        int[] fa = new int[n];
        int[] ba = new int[n];

        int need = n / 2 + n % 2;
        for(int i=0;i<n;i++){
            int tmpa = nextInt();
            fa[i] = tmpa;
            front.put(tmpa, 0);
            back.put(tmpa, 0);
            int tmpb = nextInt();
            ba[i] = tmpb;
            front.put(tmpb, 0);
            back.put(tmpb, 0);
        }

        for (int i = 0; i < n; i++) {
            int tmpa = fa[i];
            front.put(tmpa, front.get(tmpa)+1);
            int tmpb = ba[i];
            if (tmpb!=tmpa){
                back.put(tmpb,back.get(tmpb)+1);
            }
        }

        int min = Integer.MAX_VALUE;

        for (Entry<Integer,Integer> entry : front.entrySet()){
            int color = entry.getKey();
            int f = entry.getValue();
            int b = back.get(color);
            if (need <= f + b) {
                min = Math.min(min, Math.max(0, need - f));
            }
        }

        if (min == Integer.MAX_VALUE)
            min = -1;
        out.println(min);
    }

    public void close() {
        out.flush();
        out.close();
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Solver {

    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws NumberFormatException, IOException {
        Solver solver = new Solver();
        solver.open();
        long time = System.currentTimeMillis();
        solver.solve();
        if (!"true".equals(System.getProperty("ONLINE_JUDGE"))) {
            System.out.println("Spent time: " + (System.currentTimeMillis() - time));
        }
        solver.close();
    }

    public void open() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

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

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

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

    public double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }

    public void solve() throws NumberFormatException, IOException {
        int n = nextInt();

        Map<Integer, Integer> front = new HashMap<Integer, Integer>(n*10);
        Map<Integer, Integer> back = new HashMap<Integer, Integer>(n*10);

        int[] fa = new int[n];
        int[] ba = new int[n];

        int need = n / 2 + n % 2;
        for(int i=0;i<n;i++){
            int tmpa = nextInt();
            fa[i] = tmpa;
            front.put(tmpa, 0);
            back.put(tmpa, 0);
            int tmpb = nextInt();
            ba[i] = tmpb;
            front.put(tmpb, 0);
            back.put(tmpb, 0);
        }

        for (int i = 0; i < n; i++) {
            int tmpa = fa[i];
            front.put(tmpa, front.get(tmpa)+1);
            int tmpb = ba[i];
            if (tmpb!=tmpa){
                back.put(tmpb,back.get(tmpb)+1);
            }
        }

        int min = Integer.MAX_VALUE;

        for (Entry<Integer,Integer> entry : front.entrySet()){
            int color = entry.getKey();
            int f = entry.getValue();
            int b = back.get(color);
            if (need <= f + b) {
                min = Math.min(min, Math.max(0, need - f));
            }
        }

        if (min == Integer.MAX_VALUE)
            min = -1;
        out.println(min);
    }

    public void close() {
        out.flush();
        out.close();
    }

}


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

public class Solver {

    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws NumberFormatException, IOException {
        Solver solver = new Solver();
        solver.open();
        long time = System.currentTimeMillis();
        solver.solve();
        if (!"true".equals(System.getProperty("ONLINE_JUDGE"))) {
            System.out.println("Spent time: " + (System.currentTimeMillis() - time));
        }
        solver.close();
    }

    public void open() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

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

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

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

    public double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }

    public void solve() throws NumberFormatException, IOException {
        int n = nextInt();

        Map<Integer, Integer> front = new HashMap<Integer, Integer>();
        Map<Integer, Integer> back = new HashMap<Integer, Integer>();

        Set<Integer> all = new HashSet<Integer>();

        for (int i = 0; i < n; i++) {
            int a = nextInt();
            all.add(a);
            Integer e = front.get(a);
            front.put(a, e == null ? 1 : e + 1);

            int b = nextInt();
            if (b != a) {
                all.add(b);
                Integer d = back.get(b);
                back.put(b, d == null ? 1 : d + 1);
            }
        }

        int need = n / 2 + n % 2;
        int min = Integer.MAX_VALUE;

        for (int color : all) {
            Integer fo = front.get(color);
            Integer bo = back.get(color);
            int f = fo == null ? 0 : fo;
            int b = bo == null ? 0 : bo;
            if (need <= f + b) {
                min = Math.min(min, Math.max(0, need - f));
            }
        }

        if (min == Integer.MAX_VALUE)
            min = -1;
        out.println(min);
    }

    public void close() {
        out.flush();
        out.close();
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

public class Solver {

    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws NumberFormatException, IOException {
        Solver solver = new Solver();
        solver.open();
        long time = System.currentTimeMillis();
        solver.solve();
        if (!"true".equals(System.getProperty("ONLINE_JUDGE"))) {
            System.out.println("Spent time: " + (System.currentTimeMillis() - time));
        }
        solver.close();
    }

    public void open() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

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

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

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

    public double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }

    public void solve() throws NumberFormatException, IOException {
        int n = nextInt();

        Map<Integer, Integer> front = new HashMap<Integer, Integer>();
        Map<Integer, Integer> back = new HashMap<Integer, Integer>();
        Map<Integer, Integer> all = new HashMap<Integer, Integer>();

        int need = n / 2 + n % 2;

        List<Integer> may = new ArrayList<Integer>(10);

        for (int i = 0; i < n; i++) {
            int a = nextInt();
            Integer allcounto = all.get(a);
            int allcount = allcounto==null ? 1 : allcounto+1;
            all.put(a,allcount);
            if (allcount>=need){
                may.add(a);
            }
            Integer e = front.get(a);
            front.put(a, e == null ? 1 : e + 1);

            int b = nextInt();
            if (b != a) {
                allcounto = all.get(b);
                allcount = allcounto==null ? 1 : allcounto+1;
                all.put(b,allcount);
                if (allcount>=need){
                    may.add(b);
                }
                Integer d = back.get(b);
                back.put(b, d == null ? 1 : d + 1);
            }
        }

        int min = Integer.MAX_VALUE;

        for (int color : may) {
            Integer fo = front.get(color);
            Integer bo = back.get(color);
            int f = fo == null ? 0 : fo;
            int b = bo == null ? 0 : bo;
            if (need <= f + b) {
                min = Math.min(min, Math.max(0, need - f));
            }
        }

        if (min == Integer.MAX_VALUE)
            min = -1;
        out.println(min);
    }

    public void close() {
        out.flush();
        out.close();
    }

}


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

public class Solver {

    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws NumberFormatException, IOException {
        Solver solver = new Solver();
        solver.open();
        long time = System.currentTimeMillis();
        solver.solve();
        if (!"true".equals(System.getProperty("ONLINE_JUDGE"))) {
            System.out.println("Spent time: " + (System.currentTimeMillis() - time));
        }
        solver.close();
    }

    public void open() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

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

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

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

    public double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }

    public void solve() throws NumberFormatException, IOException {
        int n = nextInt();

        Map<Integer, Integer> front = new TreeMap<Integer, Integer>();
        Map<Integer, Integer> back = new TreeMap<Integer, Integer>();

        Set<Integer> all = new HashSet<Integer>();

        for (int i = 0; i < n; i++) {
            int a = nextInt();
            all.add(a);
            Integer e = front.get(a);
            front.put(a, e == null ? 1 : e + 1);

            int b = nextInt();
            if (b != a) {
                all.add(b);
                Integer d = back.get(b);
                back.put(b, d == null ? 1 : d + 1);
            }
        }

        int need = n / 2 + n % 2;
        int min = Integer.MAX_VALUE;

        for (int color : all) {
            Integer fo = front.get(color);
            Integer bo = back.get(color);
            int f = fo == null ? 0 : fo;
            int b = bo == null ? 0 : bo;
            if (need <= f + b) {
                min = Math.min(min, Math.max(0, need - f));
            }
        }

        if (min == Integer.MAX_VALUE)
            min = -1;
        out.println(min);
    }

    public void close() {
        out.flush();
        out.close();
    }

}


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

import com.sun.corba.se.impl.encoding.OSFCodeSetRegistry.Entry;
public class Main {
	static BufferedReader bf;
	static PrintWriter pw;
	static FastScanner in;

	static final int MAXN = (int) 1e5+100;
	static int n, ans=0;
	static HashMap <Integer, Pair> hm = new HashMap <Integer,Pair>();

	static int x[] = new int [MAXN];
	static int y[] = new int [MAXN];

	public static void main(String[] args) throws Exception{
		bf = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(System.out);
		in = new FastScanner(bf);

		n = in.nextInt();
		int mid = (n+1)/2;
		for (int i=1; i<=n; i++) {
			x[i] = in.nextInt();
			y[i] = in.nextInt();
		}

		for (int i=1; i<=n; i++) {
			if (!hm.containsKey(x[i])) {
				hm.put(x[i], new Pair(1,0));
			} else {
				Pair p = hm.get(x[i]);
				if ( p.a + p.b>=mid) {
					continue;
				}
				p.a++;

			}
		}

		for (int i=1; i<=n; i++) {
			if (x[i]==y[i]) continue;
			if (!hm.containsKey(y[i])) {
				hm.put(y[i], new Pair(0,1));
			} else {
				Pair p = hm.get(y[i]);
				if (p.a + p.b>=mid) {
					continue;
				}
				p.b++;
			}
		}

		int min = Integer.MAX_VALUE;
		Iterator it = hm.entrySet().iterator();
		while (it.hasNext()) {
			Map.Entry thisEntry = (Map.Entry) it.next();
			Pair p = (Pair)thisEntry.getValue();
			if (p.b + p.a >=mid) {
				if (p.b<min) {
					min = p.b;
				}
			}
		}
		if (min==Integer.MAX_VALUE) {
			pw.println(-1);
		} else {
		pw.println(min);
		}
		pw.close();
    }
}

class Pair {

	int a;
	int b;

	public Pair (int a,int b) {
		this.a = a;
		this.b = b;
	}
}
class FastScanner {

	BufferedReader reader;
	StringTokenizer strTok;

	public FastScanner(BufferedReader reader) {
		this.reader = reader;
	}

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

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

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

}