using System;
using System.Linq;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n = int.Parse(Console.ReadLine());
		int m = (int)Math.Ceiling(n / 2.0);

		var Color  = new List<int>();
		var fColor = new List<int>();
		var bColor = new List<int>();

		var ColorCount = new List<int>();
		var fColorCount = new List<int>();
		var bColorCount = new List<int>();

		for(int i = 0; i < n; i++){
			string[] line = Console.ReadLine().Split();

			int f = int.Parse(line[0]);
			int b = int.Parse(line[1]);
			int index;

			//front card
			index = Color.IndexOf(f);
			if(index != -1){ ColorCount[index]++; }
			else{ Color.Add(f); ColorCount.Add(1); }

			index = fColor.IndexOf(f);
			if(index != -1){ fColorCount[index]++; }
			else{ fColor.Add(f); fColorCount.Add(1); }

			if(f == b) continue;

			//back card
			index = Color.IndexOf(b);
			if(index != -1){ ColorCount[index]++; }
			else{ Color.Add(b); ColorCount.Add(1); }

			index = bColor.IndexOf(b);
			if(index != -1){ bColorCount[index]++; }
			else{ bColor.Add(b); bColorCount.Add(1); }
		}

		if(ColorCount.Max() < m){Console.WriteLine(-1); return;}

		int maxCount = 0;

		for(int i = 0; i < fColor.Count; i++){
			int index = Color.IndexOf(fColor[i]);
			if(fColorCount[i] < maxCount) continue;
			if(ColorCount[index] >= m){
				maxCount = fColorCount[i];
			}
		}

		if(m - maxCount > 0) Console.WriteLine(m - maxCount);
		else Console.WriteLine(0);
	}
}


using System;
using System.Linq;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n = int.Parse(Console.ReadLine());
		int m = (int)Math.Ceiling(n / 2.0);

		var Color = new HashSet<int>();
		var fColor = new List<int>();
		var bColor = new List<int>();
		var fColorCount = new List<int>();
		var bColorCount = new List<int>();

		for(int i = 0; i < n; i++){
			string[] line = Console.ReadLine().Split();
			int f = int.Parse(line[0]);
			int b = int.Parse(line[1]);

			//front
			int fi = fColor.IndexOf(f);
			if(fi != -1){
					fColorCount[fi]++;
			}else{
				fColor.Add(f);
				fColorCount.Add(1);
			}
			//back
			int bi = bColor.IndexOf(b);
			if(bi != -1){
					bColorCount[bi]++;
			}else{
				bColor.Add(b);
				bColorCount.Add(1);
			}

			Color.Add(f);
			Color.Add(b);
		}

		int min = 1000000001;
		foreach(var color in Color){
			int fi = fColor.IndexOf(color);
			int bi = bColor.IndexOf(color);

			int fc = 0;
			int bc = 0;

			if(fi != -1)
				fc = fColorCount[fi];
			if(bi != -1)
				bc = bColorCount[bi];

			if( fc + bc >= m){
				if(m - fc < min){
					min = m - fc;
					if(min < 0) min = 0;
				}
			}
		}

		if(min == 1000000001)
			Console.WriteLine(-1);
		else
			Console.WriteLine(min);
	}
}


using System;
using System.Linq;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n = int.Parse(Console.ReadLine());
		int m = (int)Math.Ceiling(n / 2.0);

		var Color  = new List<int>();
		var fColor = new List<int>();
		var bColor = new List<int>();

		var ColorCount = new List<int>();
		var fColorCount = new List<int>();
		var bColorCount = new List<int>();

		for(int i = 0; i < n; i++){
			string[] line = Console.ReadLine().Split();

			int f = int.Parse(line[0]);
			int b = int.Parse(line[1]);
			int ci = 0;

			//front card
			int fi = fColor.IndexOf(f);
			if(fi != -1){
					fColorCount[fi]++;
			}else{
				fColor.Add(f);
				fColorCount.Add(1);
			}

			ci = Color.IndexOf(f);
			if(ci != -1){
					ColorCount[ci]++;
			}else{
				Color.Add(f);
				ColorCount.Add(1);
			}
			//back card
			if(f == b) continue;

			int bi = bColor.IndexOf(b);
			if(bi != -1){
					bColorCount[bi]++;
			}else{
				bColor.Add(b);
				bColorCount.Add(1);
			}

			ci = Color.IndexOf(b);
			if(ci != -1){
					ColorCount[ci]++;
			}else{
				Color.Add(b);
				ColorCount.Add(1);
			}
		}

		int max = 0;
		foreach(var color in fColor){
			if(ColorCount[Color.IndexOf(color)] < m) continue;
			if(fColorCount[fColor.IndexOf(color)] > max)
				max = fColorCount[fColor.IndexOf(color)];
		}
		Console.WriteLine(m - max);
	}
}


using System;
using System.Linq;
using System.Collections.Generic;

class Program{
	static void Main(){
		int number = int.Parse(Console.ReadLine());
		int half = (int)Math.Ceiling(number / 2.0);

		var Color  = new Dictionary<int, int>();
		var fColor = new Dictionary<int, int>();

		for(int i = 0; i < number; i++){
			string[] line = Console.ReadLine().Split();
			int f = int.Parse(line[0]);
			int b = int.Parse(line[1]);

			//front side
			if(fColor.ContainsKey(f)){
				fColor[f]++;
				Color[f]++; //if fColor have Color have too
			}else{
				fColor.Add(f, 1);
				if(Color.ContainsKey(f))
					Color[f]++;
				else
					Color.Add(f, 1);
			}
			//back side
			if(f == b) continue;

			if(Color.ContainsKey(b))
				Color[b]++;
			else
				Color.Add(b, 1);
		}

		int min = half;
		bool possible = false;

		foreach(var iColor in Color){
			if(iColor.Value >= half){
				if(fColor.ContainsKey(iColor.Key)){
					int iMin = half - fColor[iColor.Key];
					if(iMin < min){
						min = iMin;
					}
				}
				possible = true;
			}
		}

		if(min < 0) min = 0;
		if(!possible) min = -1;

		Console.WriteLine(min);
	}
}


using System;
using System.Linq;
class Test {
    static int Main() {
        int n = int.Parse(Console.ReadLine());
        int d = n/2;
        if(n%2!=0){
            d++;
        }

        int [] x = new int[n];
        int [] y = new int[n];
        int i, j, k;

        for(i=0 ; i<n ; i++){
            string [] str = Console.ReadLine().Split();
                x[i] = int.Parse(str[0]);
                y[i] = int.Parse(str[1]);
                if(x[i]==y[i]){
                    y[i] = -1;
                }
        }

        int [] cp = new int[n];
        int [] len = new int [n];
        Array.Copy(x, cp, x.Length);
        Array.Sort(cp);
        i = j = 0;
        k = -1;
        while(true){
            j = k+1;
            k = Array.LastIndexOf(cp, cp[j]);
            len[i] = k-Array.IndexOf(cp, cp[j])+1;
            i++;
            if(j>=x.Length-1){
                break;
            }
        }

        if(len.Max()>=d){
            Console.WriteLine(0);
            return 0;
        }

        int ct = 0;
        int [] cps = new int [n];
        int [] lens = new int [n];
        Array.Copy(len, lens, len.Length);
        for(i=0, j=0 ; i<len.Length ; i++){
            if(len[i]==0){
                break;
            }
            j += len[i];
            cps[i] = cp[j-1];
        }
        Array.Sort(lens);

         k = lens.Length-1;
         i = Array.IndexOf(len, lens[k]);
        while(true){
            if(i==0){
                break;
            }
            for(j=0 ; j<n ; j++){
                if(cps[i]==y[j]){
                    ct++;
                }
            }
            if(ct+lens[k]>=d){
                Console.WriteLine(d-lens[k]);
                return 0;
            }
            ct = 0;
            i = Array.IndexOf(len, lens[k]);
            k--;
        }

        cp = new int[n];
        len = new int[n];
        Array.Copy(y, cp, y.Length);
        Array.Sort(cp);
        i = j = 0;
        k = -1;
        while(true){
            j = k+1;
            if(cp[j]!=-1){
                k = Array.LastIndexOf(cp, cp[j]);
                len[i] = k-Array.IndexOf(cp, cp[j])+1;
            }
            i++;
            if(j>=y.Length-1){
                break;
            }
        }
        Console.WriteLine(len.Max()+"this");
        if(len.Max()>=d){
            Console.WriteLine(d);
        }else{
            Console.WriteLine(-1);
        }
        return 0;
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n = int.Parse(Console.ReadLine());
		int m = (int)Math.Ceiling(n / 2.0);
		var h = new List<int>();
		var t = new List<int>();
		int[] f = new int[n];
		int[] b = new int[n];
		int[] c;

		for(int i = 0; i < n; i++){
			string[] line = Console.ReadLine().Split();

			f[i] = int.Parse(line[0]);
			b[i] = int.Parse(line[1]);

			int j = h.IndexOf(f[i]);
			if(j != -1){
				if(t[j] > 0)
					t[j]--;
			}else{
				h.Add(f[i]);
				t.Add(m - 1);
			}
		}

		if(t.Contains(0)){ Console.WriteLine(0); return;}

		c = new int[h.Count];
		int min = 1000000001;

		for(int i = 0; i < h.Count; i++){
			for(int ib = 0; ib < n; ib++){
				if(b[ib] == h[i] && f[ib] != b[ib])
					c[i]++;
			}
			if(t[i] - c[i] <= 0 && t[i] < min){
				min = t[i];
			}
		}

		if(min == 1000000001)
			Console.WriteLine(-1);
		else
			Console.WriteLine(min);
	}
}


using System;
using System.Linq;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n = int.Parse(Console.ReadLine());
		int m = (int)Math.Ceiling(n / 2.0);

		var Color = new HashSet<int>();
		var fColor = new List<int>();
		var bColor = new List<int>();
		var fColorCount = new List<int>();
		var bColorCount = new List<int>();

		for(int i = 0; i < n; i++){
			string[] line = Console.ReadLine().Split();
			int f = int.Parse(line[0]);
			int b = int.Parse(line[1]);

			//front
			int fi = fColor.IndexOf(f);
			if(fi != -1){
					fColorCount[fi]++;
			}else{
				fColor.Add(f);
				fColorCount.Add(1);
			}
			//back
			if(f == b) continue;

			int bi = bColor.IndexOf(b);
			if(bi != -1){
					bColorCount[bi]++;
			}else{
				bColor.Add(b);
				bColorCount.Add(1);
			}

			Color.Add(f);
			Color.Add(b);
		}

		int min = 1000000001;
		foreach(var color in Color){
			int fi = fColor.IndexOf(color);
			int bi = bColor.IndexOf(color);

			int fc = 0;
			int bc = 0;

			if(fi != -1)
				fc = fColorCount[fi];
			if(bi != -1)
				bc = bColorCount[bi];

			if( fc + bc >= m){
				if(m - fc < min){
					min = m - fc;
					if(min < 0) min = 0;
				}
			}
		}

		if(min == 1000000001)
			Console.WriteLine(-1);
		else
			Console.WriteLine(min);
	}
}


using System;
using System.Linq;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n = int.Parse(Console.ReadLine());
		int m = (int)Math.Ceiling(n / 2.0);

		var Color = new HashSet<int>();
		var fColor = new List<int>();
		var bColor = new List<int>();
		var fColorCount = new List<int>();
		var bColorCount = new List<int>();

		for(int i = 0; i < n; i++){
			string[] line = Console.ReadLine().Split();
			int f = int.Parse(line[0]);
			int b = int.Parse(line[1]);

			Color.Add(f);
			Color.Add(b);

			//front
			int fi = fColor.IndexOf(f);
			if(fi != -1){
					fColorCount[fi]++;
			}else{
				fColor.Add(f);
				fColorCount.Add(1);
			}
			//back
			if(f == b) continue;

			int bi = bColor.IndexOf(b);
			if(bi != -1){
					bColorCount[bi]++;
			}else{
				bColor.Add(b);
				bColorCount.Add(1);
			}
		}

		int min = 1000000001;
		foreach(var color in Color){
			int fi = fColor.IndexOf(color);
			int bi = bColor.IndexOf(color);

			int fc = 0;
			int bc = 0;

			if(fi != -1)
				fc = fColorCount[fi];
			if(bi != -1)
				bc = bColorCount[bi];
			Console.WriteLine(fc + bc);
			if( fc + bc >= m){
				if(m - fc < min){
					min = m - fc;
					if(min < 0) min = 0;
				}
			}
		}

		if(min == 1000000001)
			Console.WriteLine(-1);
		else
			Console.WriteLine(min);
	}
}


using System;
using System.Linq;
class Test {
    static int Main(){
        int n = int.Parse(Console.ReadLine());
        int [] a = new int [n];
        int [] b = new int [n];
        int i;
        for( i=0 ; i<n ; i++){
            string [] tmp = Console.ReadLine().Split();
            a[i] = int.Parse(tmp[0]);
            b[i] = int.Parse(tmp[1]);
        }
        int [] t = new int [n];
        Array.Copy(a,t,a.Length);
        Array.Sort(t);
        int [] index = new int [n];
        int [] value = new int [n];
        value[0] = t[0];
        int len = 0;
        for(int k=0, j=1, p=0 ; j<=n ; j++){
             if(j==n){
                len = j-k;
                index[p] = len;
                break;
            }
            if(t[k]!=t[j]){
                len = j-k;
                k = j;
                index[p] = len;
                value[p+1] = t[j];
                p++;
            }
        }
        int d = n/2;
        if(n%2!=0){
            d++;
        }
        int count = 0;
        if(index.Max()>=d){
            Console.WriteLine(0);
            return 0;
        }else{
            int p = 0;
            while(true){
                if(p==index.Length){
                    break;
                }
                for(i=0 ; i<n ; i++){
                    if(b[i]==value[p]){
                        if(b[i]!=a[i]){
                            count++;
                            if(count+index[p]>=d){
                                Console.WriteLine(count);
                                return 0;
                            }
                        }
                    }
                }
                p++;
                count = 0;
            }
        }
        Array.Copy(b,t,a.Length);
        Array.Sort(t);
        index = new int [n];
        value = new int [n];
        value[0] = t[0];
        len = 0;
        for(int k=0, j=1, p=0 ; j<=n ; j++){
             if(j==n){
                len = j-k;
                index[p] = len;
                break;
            }
            if(t[k]!=t[j]){
                len = j-k;
                k = j;
                index[p] = len;
                value[p+1] = t[j];
                p++;
            }
        }
       if(index.Max()>=d){
           Console.WriteLine(d);
       }else{
           Console.WriteLine(-1);
       }
       return 0;
    }
}


using System;
using System.Linq;
class Test {
    static int Main() {
        int n = int.Parse(Console.ReadLine());
        int d = n/2;
        if(n%2!=0){
            d++;
        }

        int [] x = new int[n];
        int [] y = new int[n];
        int i, j, k;

        for(i=0 ; i<n ; i++){
            string [] str = Console.ReadLine().Split();
                x[i] = int.Parse(str[0]);
                y[i] = int.Parse(str[1]);
                if(x[i]==y[i]){
                    y[i] = -1;
                }
        }

        int [] cp = new int[n];
        int [] len = new int [n];
        Array.Copy(x, cp, x.Length);
        Array.Sort(cp);
        i = j = 0;
        k = -1;
        while(true){
            j = k+1;
            k = Array.LastIndexOf(cp, cp[j]);
            len[i] = k-Array.IndexOf(cp, cp[j])+1;
            i++;
            if(j>=x.Length-1){
                break;
            }
        }

        if(len.Max()>=d){
            Console.WriteLine(0);
            return 0;
        }

        int ct = 0;
        int [] cps = new int [n];
        int [] lens = new int [n];
        Array.Copy(len, lens, len.Length);
        for(i=0, j=0 ; i<len.Length ; i++){
            j += len[i];
            cps[i] = cp[j-1];
        }
        Array.Sort(lens);

         k = lens.Length-1;
         i = Array.IndexOf(len, lens[k]);
        while(true){
            if(k<0){
                break;
            }
            for(j=0 ; j<n ; j++){
                if(cps[i]==y[j]){
                    ct++;
                }
            }
            if(ct+lens[k]>=d){
                Console.WriteLine(d-lens[k]);
                return 0;
            }
            ct = 0;
            i = Array.IndexOf(len, lens[k]);
            len[i] = -1;
            k--;
        }

        cp = new int[n];
        len = new int[n];
        Array.Copy(y, cp, y.Length);
        Array.Sort(cp);
        i = j = 0;
        k = -1;
        while(true){
            j = k+1;
            if(cp[j]!=-1){
                k = Array.LastIndexOf(cp, cp[j]);
                len[i] = k-Array.IndexOf(cp, cp[j])+1;
            }
            i++;
            if(j>=y.Length-1){
                break;
            }
        }
        if(len.Max()>=d){
            Console.WriteLine(d);
        }else{
            Console.WriteLine(-1);
        }
        return 0;
    }
}


using System;
using System.Linq;
class Test {
    static int Main() {
        int n = int.Parse(Console.ReadLine());
        int d = n/2;
        if(n%2!=0){
            d++;
        }

        int [] x = new int[n];
        int [] y = new int[n];
        int i, j, k;

        for(i=0 ; i<n ; i++){
            string [] str = Console.ReadLine().Split();
                x[i] = int.Parse(str[0]);
                y[i] = int.Parse(str[1]);
                if(x[i]==y[i]){
                    y[i] = -1;
                }
        }

        int [] cp = new int[n];
        int [] len = new int [n];
        Array.Copy(x, cp, x.Length);
        Array.Sort(cp);
        i = j = 0;;
        k = 0;
        while(true){
            k = Array.LastIndexOf(cp, cp[j]);
            len[i] = k-Array.IndexOf(cp, cp[j])+1;
            j = k+1;
            i++;
            if(j>x.Length-1){
                break;
            }
        }

        if(len.Max()>=d){
            Console.WriteLine(0);
            return 0;
        }

        int ct = 0;
        int [] cps = new int [n];
        int [] lens = new int [n];
        Array.Copy(len, lens, len.Length);
        for(i=0, j=0 ; i<len.Length ; i++){
            j += len[i];
            cps[i] = cp[j-1];
        }
        Array.Sort(lens);

         k = lens.Length-1;
         i = Array.IndexOf(len, lens[k]);
         len[i] = -1;
        while(true){
            for(j=0 ; j<n ; j++){
                if(cps[i]==y[j]){
                    ct++;
                }
            }
            if(ct+lens[k]>=d){
                Console.WriteLine(d-lens[k]);
                return 0;
            }
            if(k==0){
                break;
            }
            ct = 0;
            i = Array.IndexOf(len, lens[k]);
            len[i] = -1;
            k--;
        }

        cp = new int[n];
        len = new int[n];
        Array.Copy(y, cp, y.Length);
        Array.Sort(cp);
        i = j = 0;
        k = 0;
        while(true){
            if(cp[j]!=-1){
                k = Array.LastIndexOf(cp, cp[j]);
                len[i] = k-Array.IndexOf(cp, cp[j])+1;
            }
            j = k+1;
            i++;
            if(j>y.Length-1){
                break;
            }
        }
        if(len.Max()>=d){
            Console.WriteLine(d);
        }else{
            Console.WriteLine(-1);
        }
        return 0;
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n = int.Parse(Console.ReadLine());
		int m = (int)Math.Ceiling(n / 2.0);

		var Color  = new List<int>();
		var fColor = new List<int>();
		var bColor = new List<int>();

		var ColorCount = new List<int>();
		var fColorCount = new List<int>();
		var bColorCount = new List<int>();

		for(int i = 0; i < n; i++){
			string[] line = Console.ReadLine().Split();

			int f = int.Parse(line[0]);
			int b = int.Parse(line[1]);
			int ci = 0;

			//front card
			int fi = fColor.IndexOf(f);
			if(fi != -1){
					fColorCount[fi]++;
			}else{
				fColor.Add(f);
				fColorCount.Add(1);
			}

			ci = Color.IndexOf(f);
			if(ci != -1){
					ColorCount[ci]++;
			}else{
				Color.Add(f);
				ColorCount.Add(1);
			}
			//back card
			if(f == b) continue;

			int bi = bColor.IndexOf(b);
			if(bi != -1){
					bColorCount[bi]++;
			}else{
				bColor.Add(b);
				bColorCount.Add(1);
			}

			ci = Color.IndexOf(b);
			if(ci != -1){
					ColorCount[ci]++;
			}else{
				Color.Add(b);
				ColorCount.Add(1);
			}
		}

		int max = -1;
		foreach(var color in fColor){
			if(ColorCount[Color.IndexOf(color)] < m) continue;
			if(fColorCount[fColor.IndexOf(color)] > max)
				max = fColorCount[fColor.IndexOf(color)];
		}
		if(max == -1) Console.WriteLine(-1);
		else if(m - max < 0) Console.WriteLine(0);
		else Console.WriteLine(m - max);
	}
}


using System;
using System.Linq;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n = int.Parse(Console.ReadLine());
		int m = (int)Math.Ceiling(n / 2.0);

		var Color  = new List<int>();
		var fColor = new List<int>();
		var bColor = new List<int>();

		var ColorCount = new List<int>();
		var fColorCount = new List<int>();
		var bColorCount = new List<int>();

		for(int i = 0; i < n; i++){
			string[] line = Console.ReadLine().Split();

			int f = int.Parse(line[0]);
			int b = int.Parse(line[1]);
			int index;

			//front card
			index = Color.IndexOf(f);
			if(index != -1){ ColorCount[index]++; }
			else{ Color.Add(f); ColorCount.Add(1); }

			index = fColor.IndexOf(f);
			if(index != -1){ fColorCount[index]++; }
			else{ fColor.Add(f); fColorCount.Add(1); }

			if(f == b) continue;

			//back card
			index = Color.IndexOf(b);
			if(index != -1){ ColorCount[index]++; }
			else{ Color.Add(b); ColorCount.Add(1); }

			index = bColor.IndexOf(b);
			if(index != -1){ bColorCount[index]++; }
			else{ bColor.Add(b); bColorCount.Add(1); }
		}

		if(ColorCount.Max() < m){Console.WriteLine(-1); return;}

		int maxCount = 0;

		for(int i = 0; i < fColor.Count; i++){
			int index = Color.IndexOf(fColor[i]);
			if(ColorCount[index] >= m && fColorCount[i] > maxCount){
				maxCount = fColorCount[i];
			}
		}

		if(m - maxCount > 0) Console.WriteLine(m - maxCount);
		else Console.WriteLine(0);
	}
}


using System;
using System.Linq;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n = int.Parse(Console.ReadLine());
		int m = (int)Math.Ceiling(n / 2.0);

		var Color  = new List<int>();
		var fColor = new List<int>();
		var bColor = new List<int>();

		var ColorCount = new List<int>();
		var fColorCount = new List<int>();
		var bColorCount = new List<int>();

		for(int i = 0; i < n; i++){
			string[] line = Console.ReadLine().Split();

			int f = int.Parse(line[0]);
			int b = int.Parse(line[1]);
			int ci = 0;

			//front card
			int fi = fColor.IndexOf(f);
			if(fi != -1){
					fColorCount[fi]++;
			}else{
				fColor.Add(f);
				fColorCount.Add(1);
			}

			ci = Color.IndexOf(f);
			if(ci != -1){
					ColorCount[ci]++;
			}else{
				Color.Add(f);
				ColorCount.Add(1);
			}
			//back card
			if(f == b) continue;

			int bi = bColor.IndexOf(b);
			if(bi != -1){
					bColorCount[bi]++;
			}else{
				bColor.Add(b);
				bColorCount.Add(1);
			}

			ci = Color.IndexOf(b);
			if(ci != -1){
					ColorCount[ci]++;
			}else{
				Color.Add(b);
				ColorCount.Add(1);
			}
		}

		if(ColorCount.Max() < m){Console.WriteLine(-1); return;}

		int max = 0;
		foreach(var color in fColor){
			if(ColorCount[Color.IndexOf(color)] < m) continue;
			if(fColorCount[fColor.IndexOf(color)] > max)
				max = fColorCount[fColor.IndexOf(color)];
		}
		if(max == -1) Console.WriteLine(-1);
		else if(m - max < 0) Console.WriteLine(0);
		else Console.WriteLine(m - max);
	}
}


using System;
using System.Linq;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n = int.Parse(Console.ReadLine());
		int m = (int)Math.Ceiling(n / 2.0);

		var Color  = new List<int>();
		var fColor = new List<int>();
		var bColor = new List<int>();

		var ColorCount = new List<int>();
		var fColorCount = new List<int>();
		var bColorCount = new List<int>();

		for(int i = 0; i < n; i++){
			string[] line = Console.ReadLine().Split();

			int f = int.Parse(line[0]);
			int b = int.Parse(line[1]);
			int ci = 0;

			//front card
			int fi = fColor.IndexOf(f);
			if(fi != -1){
					fColorCount[fi]++;
			}else{
				fColor.Add(f);
				fColorCount.Add(1);
			}

			ci = Color.IndexOf(f);
			if(ci != -1){
					ColorCount[ci]++;
			}else{
				Color.Add(f);
				ColorCount.Add(1);
			}
			//back card
			if(f == b) continue;

			int bi = bColor.IndexOf(b);
			if(bi != -1){
					bColorCount[bi]++;
			}else{
				bColor.Add(b);
				bColorCount.Add(1);
			}

			ci = Color.IndexOf(b);
			if(ci != -1){
					ColorCount[ci]++;
			}else{
				Color.Add(b);
				ColorCount.Add(1);
			}
		}

		int max = 0;
		foreach(var color in fColor){
			if(ColorCount[Color.IndexOf(color)] < m) continue;
			if(fColorCount[fColor.IndexOf(color)] > max)
				max = fColorCount[fColor.IndexOf(color)];
		}
		if(m - max < 0) Console.WriteLine(0);
		else Console.WriteLine(m - max);
	}
}


using System;
using System.Linq;
class Test {
    static int Main() {
        int n = int.Parse(Console.ReadLine());
        int d = n/2;
        if(n%2!=0){
            d++;
        }

        int [] x = new int[n];
        int [] y = new int[n];
        int i, j, k;

        for(i=0 ; i<n ; i++){
            string [] str = Console.ReadLine().Split();
                x[i] = int.Parse(str[0]);
                y[i] = int.Parse(str[1]);
                if(x[i]==y[i]){
                    y[i] = -1;
                }
        }

        int [] cp = new int[n];
        int [] len = new int [n];
        Array.Copy(x, cp, x.Length);
        Array.Sort(cp);
        i = j = 0;;
        k = 0;
        while(true){
            k = Array.LastIndexOf(cp, cp[j]);
            len[i] = k-Array.IndexOf(cp, cp[j])+1;
            j = k+1;
            i++;
            if(j>x.Length-1){
                break;
            }
        }

        if(len.Max()>=d){
            Console.WriteLine(0);
            return 0;
        }

        int ct = 0;
        int [] cps = new int [n];
        int [] lens = new int [n];
        Array.Copy(len, lens, len.Length);
        for(i=0, j=0 ; i<len.Length ; i++){
            j += len[i];
            cps[i] = cp[j-1];
        }
        Array.Sort(lens);

         k = lens.Length-1;
         i = Array.IndexOf(len, lens[k]);
        while(true){
            if(k<0){
                break;
            }
            for(j=0 ; j<n ; j++){
                if(cps[i]==y[j]){
                    ct++;
                }
            }
            if(ct+lens[k]>=d){
                Console.WriteLine(d-lens[k]);
                return 0;
            }
            ct = 0;
            i = Array.IndexOf(len, lens[k]);
            len[i] = -1;
            k--;
        }

        cp = new int[n];
        len = new int[n];
        Array.Copy(y, cp, y.Length);
        Array.Sort(cp);
        i = j = 0;
        k = 0;
        while(true){
            if(cp[j]!=-1){
                k = Array.LastIndexOf(cp, cp[j]);
                len[i] = k-Array.IndexOf(cp, cp[j])+1;
            }
            j = k+1;
            i++;
            if(j>y.Length-1){
                break;
            }
        }
        if(len.Max()>=d){
            Console.WriteLine(d);
        }else{
            Console.WriteLine(-1);
        }
        return 0;
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n = int.Parse(Console.ReadLine());
		int m = (int)Math.Ceiling(n / 2.0);

		var Color = new HashSet<int>();
		var fColor = new List<int>();
		var bColor = new List<int>();
		var fColorCount = new List<int>();
		var bColorCount = new List<int>();

		for(int i = 0; i < n; i++){
			string[] line = Console.ReadLine().Split();
			int f = int.Parse(line[0]);
			int b = int.Parse(line[1]);

			//front
			int fi = fColor.IndexOf(f);
			if(fi != -1){
					fColorCount[fi]++;
			}else{
				fColor.Add(f);
				fColorCount.Add(1);
			}
			//back
			int bi = bColor.IndexOf(b);
			if(bi != -1){
					bColorCount[bi]++;
			}else{
				bColor.Add(b);
				bColorCount.Add(1);
			}

			Color.Add(f);
			Color.Add(b);
		}

		int min = int.MaxValue;
		foreach(var color in Color){
			int fi = fColor.IndexOf(color);
			int bi = bColor.IndexOf(color);

			int fc = 0;
			int bc = 0;

			if(fi != -1)
				fc = fColorCount[fi];
			if(bi != -1)
				bc = bColorCount[bi];

			if( fc + bc >= m){
				if(m - fc < min){
					min = m - fc;
				}
			}
		}

		Console.WriteLine(min);
	}
}


using System;
using System.Linq;
class Test {
    static int Main(){
        int n = int.Parse(Console.ReadLine());
        int [] a = new int [n];
        int [] b = new int [n];
        int i;
        for( i=0 ; i<n ; i++){
            string [] tmp = Console.ReadLine().Split();
            a[i] = int.Parse(tmp[0]);
            b[i] = int.Parse(tmp[1]);
        }
        int [] t = new int [n];
        Array.Copy(a,t,a.Length);
        Array.Sort(t);
        int [] index = new int [n];
        int [] value = new int [n];
        value[0] = t[0];
        int len = 0;
        for(int k=0, j=1, p=0 ; j<=n ; j++){
             if(j==n){
                len = j-k;
                index[p] = len;
                break;
            }
            if(t[k]!=t[j]){
                len = j-k;
                k = j;
                index[p] = len;
                value[p+1] = t[j];
                p++;
            }
        }
        int d = n/2;
        if(n%2!=0){
            d++;
        }
        int count = 0;
        if(index.Max()>=d){
            Console.WriteLine(0);
            return 0;
        }else{
            int p = 0;
            while(true){
                if(p==index.Length){
                    Console.WriteLine(-1);
                    return 0;
                }
                for(i=0 ; i<n ; i++){
                    if(b[i]==value[p]){
                        if(b[i]!=a[i]){
                            count++;
                            if(count+index[p]>=d){
                                Console.WriteLine(count);
                                return 0;
                            }
                        }
                    }
                }
                p++;
                count = 0;
            }
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n = int.Parse(Console.ReadLine());
		int m = (int)Math.Ceiling(n / 2.0);

		var Color  = new List<int>();
		var fColor = new List<int>();
		var bColor = new List<int>();

		var ColorCount = new List<int>();
		var fColorCount = new List<int>();
		var bColorCount = new List<int>();

		for(int i = 0; i < n; i++){
			string[] line = Console.ReadLine().Split();

			int f = int.Parse(line[0]);
			int b = int.Parse(line[1]);
			int ci = 0;

			//front card
			int fi = fColor.IndexOf(f);
			if(fi != -1){
					fColorCount[fi]++;
			}else{
				fColor.Add(f);
				fColorCount.Add(1);
			}

			ci = Color.IndexOf(f);
			if(ci != -1){
					ColorCount[ci]++;
			}else{
				Color.Add(f);
				ColorCount.Add(1);
			}
			//back card
			if(f == b) continue;

			int bi = bColor.IndexOf(b);
			if(bi != -1){
					bColorCount[bi]++;
			}else{
				bColor.Add(b);
				bColorCount.Add(1);
			}

			ci = Color.IndexOf(b);
			if(ci != -1){
					ColorCount[ci]++;
			}else{
				Color.Add(b);
				ColorCount.Add(1);
			}
		}

		if(ColorCount.Max() < m){Console.WriteLine(-1); return;}

		int max = 0;
		while(true){
			int countmax = fColorCount.Max();
			int icountmax = fColorCount.IndexOf(countmax);
			int color = fColor[icountmax];

			if(countmax == -1) break;

			int icolor = Color.IndexOf(color);
			if(ColorCount[icolor] < m){
				fColorCount[icountmax] = -1;
				continue;
			}
			max = fColorCount[icountmax];
			break;
		}
		if(m - max > 0)
			Console.WriteLine(m - max);
		else
			Console.WriteLine(0);
	}
}


using System;
using System.Linq;
class Test {
    static int Main() {
        int n = int.Parse(Console.ReadLine());
        int d = n/2;
        if(n%2!=0){
            d++;
        }

        int [] x = new int[n];
        int [] y = new int[n];
        int i, j, k;

        for(i=0 ; i<n ; i++){
            string [] str = Console.ReadLine().Split();
                x[i] = int.Parse(str[0]);
                y[i] = int.Parse(str[1]);
                if(x[i]==y[i]){
                    y[i] = -1;
                }
        }

        int [] cp = new int[n];
        int [] len = new int [n];
        Array.Copy(x, cp, x.Length);
        Array.Sort(cp);
        i = j = 0;;
        k = 0;
        while(true){
            k = Array.LastIndexOf(cp, cp[j]);
            len[i] = k-Array.IndexOf(cp, cp[j])+1;
            j = k+1;
            i++;
            if(j>x.Length-1){
                break;
            }
        }

        if(len.Max()>=d){
            Console.WriteLine(0);
            return 0;
        }

        int ct = 0;
        int [] cps = new int [n];
        int [] lens = new int [n];
        Array.Copy(len, lens, len.Length);
        for(i=0, j=0 ; i<len.Length ; i++){
            j += len[i];
            cps[i] = cp[j-1];
        }
        Array.Sort(lens);

         k = lens.Length-1;
         i = Array.IndexOf(len, lens[k]);
         len[i] = -1;
        while(true){
            if(k<0){
                break;
            }
            for(j=0 ; j<n ; j++){
                if(cps[i]==y[j]){
                    ct++;
                }
            }
            if(ct+lens[k]>=d){
                Console.WriteLine(d-lens[k]);
                return 0;
            }
            ct = 0;
            i = Array.IndexOf(len, lens[k]);
            len[i] = -1;
            k--;
        }

        cp = new int[n];
        len = new int[n];
        Array.Copy(y, cp, y.Length);
        Array.Sort(cp);
        i = j = 0;
        k = 0;
        while(true){
            if(cp[j]!=-1){
                k = Array.LastIndexOf(cp, cp[j]);
                len[i] = k-Array.IndexOf(cp, cp[j])+1;
            }
            j = k+1;
            i++;
            if(j>y.Length-1){
                break;
            }
        }
        if(len.Max()>=d){
            Console.WriteLine(d);
        }else{
            Console.WriteLine(-1);
        }
        return 0;
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n = int.Parse(Console.ReadLine());
		int m = (int)Math.Ceiling(n / 2.0);

		var Color  = new List<int>();
		var fColor = new List<int>();
		var bColor = new List<int>();

		var ColorCount = new List<int>();
		var fColorCount = new List<int>();
		var bColorCount = new List<int>();

		for(int i = 0; i < n; i++){
			string[] line = Console.ReadLine().Split();

			int f = int.Parse(line[0]);
			int b = int.Parse(line[1]);
			int ci = 0;

			//front card
			int fi = fColor.IndexOf(f);
			if(fi != -1){
					fColorCount[fi]++;
			}else{
				fColor.Add(f);
				fColorCount.Add(1);
			}

			ci = Color.IndexOf(f);
			if(ci != -1){
					ColorCount[ci]++;
			}else{
				Color.Add(f);
				ColorCount.Add(1);
			}
			//back card
			if(f == b) continue;

			int bi = bColor.IndexOf(b);
			if(bi != -1){
					bColorCount[bi]++;
			}else{
				bColor.Add(b);
				bColorCount.Add(1);
			}

			ci = Color.IndexOf(b);
			if(ci != -1){
					ColorCount[ci]++;
			}else{
				Color.Add(b);
				ColorCount.Add(1);
			}
		}

		int max = -1;
		foreach(var color in fColor){
			if(ColorCount[Color.IndexOf(color)] < m) continue;
			if(fColorCount[fColor.IndexOf(color)] > max)
				max = fColorCount[fColor.IndexOf(color)];
			else max = 0;
		}
		if(max == -1) Console.WriteLine(-1);
		else if(m - max < 0) Console.WriteLine(0);
		else Console.WriteLine(m - max);
	}
}


using System;
using System.Linq;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n = int.Parse(Console.ReadLine());
		int m = (int)Math.Ceiling(n / 2.0);

		var Color  = new List<int>();
		var fColor = new List<int>();
		var bColor = new List<int>();

		var ColorCount = new List<int>();
		var fColorCount = new List<int>();
		var bColorCount = new List<int>();

		for(int i = 0; i < n; i++){
			string[] line = Console.ReadLine().Split();

			int f = int.Parse(line[0]);
			int b = int.Parse(line[1]);
			int index;

			//front card
			index = Color.IndexOf(f);
			if(index != -1){ ColorCount[index]++; }
			else{ Color.Add(f); ColorCount.Add(1); }

			index = fColor.IndexOf(f);
			if(index != -1){ fColorCount[index]++; }
			else{ fColor.Add(f); fColorCount.Add(1); }

			if(f == b) continue;

			//back card
			index = Color.IndexOf(b);
			if(index != -1){ ColorCount[index]++; }
			else{ Color.Add(b); ColorCount.Add(1); }

			index = bColor.IndexOf(b);
			if(index != -1){ bColorCount[index]++; }
			else{ bColor.Add(b); bColorCount.Add(1); }
		}

		if(ColorCount.Max() < m){Console.WriteLine(-1); return;}

		int maxCount = 0;

		for(int i = 0; i < fColor; i++;){
			int index = Color.indexOf(fColor[i]);
			if(ColorCount[index] >= m){
				maxCount = fColorCount[i];
			}
		}

		if(m - maxCount > 0) Console.WriteLine(m - maxCount);
		else Console.WriteLine(0);
	}
}


using System;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Globalization;
using System.Collections.Generic;
using System.Threading;

namespace CodeForces
{
	internal class B
	{

		private void Solve()
		{
			int n = NextInt();
			int[] a = new int[n], b = new int[n];
			Dictionary<int, int> cnt = new Dictionary<int, int>();
			for ( int i = 0; i < n; ++i )
			{
				a[i] = NextInt();
				b[i] = NextInt();
				if ( cnt.ContainsKey( a[i] ) )
					cnt[a[i]]++;
				else
				{
					cnt.Add( a[i], 1 );
				}
				if ( cnt.ContainsKey( b[i] ) )
					cnt[b[i]]++;
				else
				{
					cnt.Add( b[i], 1 );
				}
			}
			List<int> check = new List<int>();
			foreach ( var pair in cnt )
			{
				if ( 2 * pair.Value >= n )
				{
					check.Add( pair.Key );
				}
			}

			int best = int.MaxValue;
			foreach ( var c in check )
			{
				int tmp = 0;
				bool can = true;
				int have = 0;
				for ( int i = 0; i < n; ++i ) if ( a[i] == c ) ++have;

				if ( have * 2 < n )
				{
					for ( int i = 0; i < n; ++i ) if ( a[i] != c && b[i] == c )
						{
							++have;
							++tmp;
							if ( have * 2 >= n ) break;
						}
					if ( have * 2 < n ) can = false;
				}

				if ( can )
					best = Math.Min( best, tmp );
			}

			Out.WriteLine( best == int.MaxValue ? -1 : best );
		}

		#region Local wireup

		public int NextInt()
		{
			return _in.NextInt();
		}

		public long NextLong()
		{
			return _in.NextLong();
		}

		public string NextLine()
		{
			return _in.NextLine();
		}

		public double NextDouble()
		{
			return _in.NextDouble();
		}

		readonly Scanner _in = new Scanner();
		static readonly TextWriter Out = Console.Out;

		void Start()
		{
#if !ONLINE_JUDGE
			var timer = new Stopwatch();
			timer.Start();
#endif
			var t = new Thread( Solve, 20000000 );
			t.Start();
			t.Join();
#if !ONLINE_JUDGE
			timer.Stop();
			Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "Done in {0} seconds.\nPress <Enter> to exit.", timer.ElapsedMilliseconds / 1000.0 ) );
			Console.ReadLine();
#endif
		}

		static void Main()
		{
			new B().Start();
		}

		class Scanner : IDisposable
		{
			#region Fields

			readonly TextReader _reader;
			readonly int _bufferSize;
			readonly bool _closeReader;
			readonly char[] _buffer;
			int _length, _pos;

			#endregion

			#region .ctors

			public Scanner( TextReader reader, int bufferSize, bool closeReader )
			{
				_reader = reader;
				_bufferSize = bufferSize;
				_closeReader = closeReader;
				_buffer = new char[_bufferSize];
				FillBuffer( false );
			}

			public Scanner( TextReader reader, bool closeReader ) : this( reader, 1 << 16, closeReader ) { }

			public Scanner( string fileName ) : this( new StreamReader( fileName, Encoding.Default ), true ) { }

#if ONLINE_JUDGE
			public Scanner() : this( Console.In, false ) { }
#else
			public Scanner() : this( "input.txt" ) { }
#endif

			#endregion

			#region IDisposable Members

			public void Dispose()
			{
				if ( _closeReader )
				{
					_reader.Close();
				}
			}

			#endregion

			#region Properties

			public bool Eof
			{
				get
				{
					if ( _pos < _length ) return false;
					FillBuffer( false );
					return _pos >= _length;
				}
			}

			#endregion

			#region Methods

			private char NextChar()
			{
				if ( _pos < _length ) return _buffer[_pos++];
				FillBuffer( true );
				return _buffer[_pos++];
			}

			private char PeekNextChar()
			{
				if ( _pos < _length ) return _buffer[_pos];
				FillBuffer( true );
				return _buffer[_pos];
			}

			private void FillBuffer( bool throwOnEof )
			{
				_length = _reader.Read( _buffer, 0, _bufferSize );
				if ( throwOnEof && Eof )
				{
					throw new IOException( "Can't read beyond the end of file" );
				}
				_pos = 0;
			}

			public int NextInt()
			{
				var neg = false;
				int res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public long NextLong()
			{
				var neg = false;
				long res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public string NextLine()
			{
				SkipUntilNextLine();
				if ( Eof ) return "";
				var builder = new StringBuilder();
				while ( !Eof && !IsEndOfLine( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return builder.ToString();
			}

			public double NextDouble()
			{
				SkipWhitespaces();
				var builder = new StringBuilder();
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return double.Parse( builder.ToString(), CultureInfo.InvariantCulture );
			}

			private void SkipWhitespaces()
			{
				while ( !Eof && IsWhitespace( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private void SkipUntilNextLine()
			{
				while ( !Eof && IsEndOfLine( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private static bool IsWhitespace( char c )
			{
				return c == ' ' || c == '\t' || c == '\n' || c == '\r';
			}

			private static bool IsEndOfLine( char c )
			{
				return c == '\n' || c == '\r';
			}

			#endregion
		}

		#endregion
	}
}


using System;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Globalization;
using System.Collections.Generic;
using System.Threading;

namespace CodeForces
{
	internal class B
	{

		private void Solve()
		{
			int n = NextInt();
			int[] a = new int[n], b = new int[n];
			Dictionary<int, int> cnt = new Dictionary<int, int>();
			for ( int i = 0; i < n; ++i )
			{
				a[i] = NextInt();
				b[i] = NextInt();
				if ( cnt.ContainsKey( a[i] ) )
					cnt[a[i]]++;
				else
				{
					cnt.Add( a[i], 1 );
				}
				if ( cnt.ContainsKey( b[i] ) )
					cnt[b[i]]++;
				else
				{
					cnt.Add( b[i], 1 );
				}
			}
			List<int> check = new List<int>();
			foreach ( var pair in cnt )
			{
				if ( 2 * pair.Value >= n )
				{
					check.Add( pair.Key );
				}
			}

			int best = int.MaxValue;
			foreach ( var c in check )
			{
				int tmp = 0;
				bool can = true;
				int have = 0;
				for ( int i = 0; i < n; ++i ) if ( a[i] == c ) ++have;

				if ( have * 2 < n )
				{
					for ( int i = 0; i < n; ++i ) if ( a[i] != c && b[i] == c )
						{
							++have;
							++tmp;
						}
					if ( have * 2 < n ) can = false;
				}

				if ( can )
					best = Math.Min( best, tmp );
			}

			Out.WriteLine( best == int.MaxValue ? -1 : best );
		}

		#region Local wireup

		public int NextInt()
		{
			return _in.NextInt();
		}

		public long NextLong()
		{
			return _in.NextLong();
		}

		public string NextLine()
		{
			return _in.NextLine();
		}

		public double NextDouble()
		{
			return _in.NextDouble();
		}

		readonly Scanner _in = new Scanner();
		static readonly TextWriter Out = Console.Out;

		void Start()
		{
#if !ONLINE_JUDGE
			var timer = new Stopwatch();
			timer.Start();
#endif
			var t = new Thread( Solve, 20000000 );
			t.Start();
			t.Join();
#if !ONLINE_JUDGE
			timer.Stop();
			Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "Done in {0} seconds.\nPress <Enter> to exit.", timer.ElapsedMilliseconds / 1000.0 ) );
			Console.ReadLine();
#endif
		}

		static void Main()
		{
			new B().Start();
		}

		class Scanner : IDisposable
		{
			#region Fields

			readonly TextReader _reader;
			readonly int _bufferSize;
			readonly bool _closeReader;
			readonly char[] _buffer;
			int _length, _pos;

			#endregion

			#region .ctors

			public Scanner( TextReader reader, int bufferSize, bool closeReader )
			{
				_reader = reader;
				_bufferSize = bufferSize;
				_closeReader = closeReader;
				_buffer = new char[_bufferSize];
				FillBuffer( false );
			}

			public Scanner( TextReader reader, bool closeReader ) : this( reader, 1 << 16, closeReader ) { }

			public Scanner( string fileName ) : this( new StreamReader( fileName, Encoding.Default ), true ) { }

#if ONLINE_JUDGE
			public Scanner() : this( Console.In, false ) { }
#else
			public Scanner() : this( "input.txt" ) { }
#endif

			#endregion

			#region IDisposable Members

			public void Dispose()
			{
				if ( _closeReader )
				{
					_reader.Close();
				}
			}

			#endregion

			#region Properties

			public bool Eof
			{
				get
				{
					if ( _pos < _length ) return false;
					FillBuffer( false );
					return _pos >= _length;
				}
			}

			#endregion

			#region Methods

			private char NextChar()
			{
				if ( _pos < _length ) return _buffer[_pos++];
				FillBuffer( true );
				return _buffer[_pos++];
			}

			private char PeekNextChar()
			{
				if ( _pos < _length ) return _buffer[_pos];
				FillBuffer( true );
				return _buffer[_pos];
			}

			private void FillBuffer( bool throwOnEof )
			{
				_length = _reader.Read( _buffer, 0, _bufferSize );
				if ( throwOnEof && Eof )
				{
					throw new IOException( "Can't read beyond the end of file" );
				}
				_pos = 0;
			}

			public int NextInt()
			{
				var neg = false;
				int res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public long NextLong()
			{
				var neg = false;
				long res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public string NextLine()
			{
				SkipUntilNextLine();
				if ( Eof ) return "";
				var builder = new StringBuilder();
				while ( !Eof && !IsEndOfLine( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return builder.ToString();
			}

			public double NextDouble()
			{
				SkipWhitespaces();
				var builder = new StringBuilder();
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return double.Parse( builder.ToString(), CultureInfo.InvariantCulture );
			}

			private void SkipWhitespaces()
			{
				while ( !Eof && IsWhitespace( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private void SkipUntilNextLine()
			{
				while ( !Eof && IsEndOfLine( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private static bool IsWhitespace( char c )
			{
				return c == ' ' || c == '\t' || c == '\n' || c == '\r';
			}

			private static bool IsEndOfLine( char c )
			{
				return c == '\n' || c == '\r';
			}

			#endregion
		}

		#endregion
	}
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;

namespace Codeforces
{
    class B
    {
        private static ThreadStart s_threadStart = new B().Go;
        private static bool s_time = false;

        private void Go()
        {
            int n = GetInt();
            Dictionary<int, int> total = new Dictionary<int, int>();
            Dictionary<int, int> up = new Dictionary<int, int>();

            for (int i = 0; i < n; i++)
            {
                int tmp;
                int a = GetInt();
                if (!total.TryGetValue(a, out tmp))
                {
                    tmp = 0;
                }
                total[a] = tmp + 1;

                if (!up.TryGetValue(a, out tmp))
                {
                    tmp = 0;
                }
                up[a] = tmp + 1;

                int b = GetInt();
                if (b != a)
                {
                    if (!total.TryGetValue(b, out tmp))
                    {
                        tmp = 0;
                    }
                    total[b] = tmp + 1;
                    if (!up.TryGetValue(b, out tmp))
                    {
                        up[b] = 0;
                    }
                }
            }

            int ret = int.MaxValue;
            int half = (n+1) / 2;
            foreach (int x in total.Keys)
            {
                if (total[x] >= half)
                {
                    int t = half - up[x];
                    if (ret > t) ret = t;
                    if (ret <= 0)
                    {
                        Wl(0);
                        return;
                    }
                }
            }
            if (ret == int.MaxValue) ret = -1;
            Wl(ret);
        }

        #region Template

        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);
            timer.Start();
            main.Start();
            main.Join();
            timer.Stop();
            if (s_time)
                Wl(timer.ElapsedMilliseconds);
        }

        private static IEnumerator<string> ioEnum;
        private static string GetString()
        {
            while (ioEnum == null || !ioEnum.MoveNext())
            {
                ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();
            }

            return ioEnum.Current;
        }

        private static int GetInt()
        {
            return int.Parse(GetString());
        }

        private static long GetLong()
        {
            return long.Parse(GetString());
        }

        private static double GetDouble()
        {
            return double.Parse(GetString());
        }

        private static List<int> GetIntArr(int n)
        {
            List<int> ret = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                ret.Add(GetInt());
            }
            return ret;
        }

        private static void Wl<T>(T o)
        {
            if (o is double)
            {
                Wld((o as double?).Value, "");
            }
            else if (o is float)
            {
                Wld((o as float?).Value, "");
            }
            else
                Console.WriteLine(o.ToString());
        }

        private static void Wl<T>(IEnumerable<T> enumerable)
        {
            Wl(string.Join(" ", enumerable.Select(e => e.ToString()).ToArray()));
        }

        private static void Wld(double d, string format)
        {
            Wl(d.ToString(format, CultureInfo.InvariantCulture));
        }

        public struct Tuple<T, K> : IComparable<Tuple<T, K>>
            where T : IComparable<T>
            where K : IComparable<K>
        {
            public T Item1;
            public K Item2;

            public Tuple(T t, K k)
            {
                Item1 = t;
                Item2 = k;
            }

            public override bool Equals(object obj)
            {
                var o = (Tuple<T, K>)obj;
                return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);
            }

            public override int GetHashCode()
            {
                return Item1.GetHashCode() ^ Item2.GetHashCode();
            }

            public override string ToString()
            {
                return "(" + Item1 + " " + Item2 + ")";
            }

            #region IComparable<Tuple<T,K>> Members

            public int CompareTo(Tuple<T, K> other)
            {
                int ret = Item1.CompareTo(other.Item1);
                if (ret != 0) return ret;
                return Item2.CompareTo(other.Item2);
            }

            #endregion
        }

        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;

namespace Codeforces
{
    class B
    {
        private static ThreadStart s_threadStart = new B().Go;
        private static bool s_time = false;

        private void Go()
        {
            int n = GetInt();
            Dictionary<int, int> total = new Dictionary<int, int>();
            Dictionary<int, int> up = new Dictionary<int, int>();

            for (int i = 0; i < n; i++)
            {
                int tmp;
                int a = GetInt();
                if (!total.TryGetValue(a, out tmp))
                {
                    tmp = 0;
                }
                total[a] = tmp + 1;

                if (!up.TryGetValue(a, out tmp))
                {
                    tmp = 0;
                }
                up[a] = tmp + 1;

                int b = GetInt();
                if (b != a)
                {
                    if (!total.TryGetValue(b, out tmp))
                    {
                        tmp = 0;
                    }
                    total[b] = tmp + 1;
                    if (!up.TryGetValue(b, out tmp))
                    {
                        up[b] = 0;
                    }
                }
            }

            int ret = int.MaxValue;
            int half = (n+1) / 2;
            foreach (int x in total.Keys)
            {
                if (total[x] >= half)
                {
                    int t = half - up[x];
                    if (ret > t) ret = t;
                }
            }
            if (ret == int.MaxValue) ret = -1;
            Wl(ret);
        }

        #region Template

        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);
            timer.Start();
            main.Start();
            main.Join();
            timer.Stop();
            if (s_time)
                Wl(timer.ElapsedMilliseconds);
        }

        private static IEnumerator<string> ioEnum;
        private static string GetString()
        {
            while (ioEnum == null || !ioEnum.MoveNext())
            {
                ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();
            }

            return ioEnum.Current;
        }

        private static int GetInt()
        {
            return int.Parse(GetString());
        }

        private static long GetLong()
        {
            return long.Parse(GetString());
        }

        private static double GetDouble()
        {
            return double.Parse(GetString());
        }

        private static List<int> GetIntArr(int n)
        {
            List<int> ret = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                ret.Add(GetInt());
            }
            return ret;
        }

        private static void Wl<T>(T o)
        {
            if (o is double)
            {
                Wld((o as double?).Value, "");
            }
            else if (o is float)
            {
                Wld((o as float?).Value, "");
            }
            else
                Console.WriteLine(o.ToString());
        }

        private static void Wl<T>(IEnumerable<T> enumerable)
        {
            Wl(string.Join(" ", enumerable.Select(e => e.ToString()).ToArray()));
        }

        private static void Wld(double d, string format)
        {
            Wl(d.ToString(format, CultureInfo.InvariantCulture));
        }

        public struct Tuple<T, K> : IComparable<Tuple<T, K>>
            where T : IComparable<T>
            where K : IComparable<K>
        {
            public T Item1;
            public K Item2;

            public Tuple(T t, K k)
            {
                Item1 = t;
                Item2 = k;
            }

            public override bool Equals(object obj)
            {
                var o = (Tuple<T, K>)obj;
                return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);
            }

            public override int GetHashCode()
            {
                return Item1.GetHashCode() ^ Item2.GetHashCode();
            }

            public override string ToString()
            {
                return "(" + Item1 + " " + Item2 + ")";
            }

            #region IComparable<Tuple<T,K>> Members

            public int CompareTo(Tuple<T, K> other)
            {
                int ret = Item1.CompareTo(other.Item1);
                if (ret != 0) return ret;
                return Item2.CompareTo(other.Item2);
            }

            #endregion
        }

        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;

namespace Codeforces
{
    class B
    {
        private static ThreadStart s_threadStart = new B().Go;
        private static bool s_time = false;

        private void Go()
        {
            int n = GetInt();
            Dictionary<int, int> total = new Dictionary<int, int>();
            Dictionary<int, int> up = new Dictionary<int, int>();

            for (int i = 0; i < n; i++)
            {
                int tmp;
                int a = GetInt();
                if (!total.TryGetValue(a, out tmp))
                {
                    tmp = 0;
                }
                total[a] = tmp + 1;

                if (!up.TryGetValue(a, out tmp))
                {
                    tmp = 0;
                }
                up[a] = tmp + 1;
                int b = GetInt();
                if (!total.TryGetValue(b, out tmp))
                {
                    tmp = 0;
                }
                total[b] = tmp + 1;
                if (!up.TryGetValue(b, out tmp))
                {
                    up[b] = 0;
                }
            }

            int ret = int.MaxValue;
            int half = (n+1) / 2;
            foreach (int x in total.Keys)
            {
                if (total[x] >= half)
                {
                    int t = half - up[x];
                    if (ret > t) ret = t;
                }
            }
            if (ret == int.MaxValue) ret = -1;
            Wl(ret);
        }

        #region Template

        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);
            timer.Start();
            main.Start();
            main.Join();
            timer.Stop();
            if (s_time)
                Wl(timer.ElapsedMilliseconds);
        }

        private static IEnumerator<string> ioEnum;
        private static string GetString()
        {
            while (ioEnum == null || !ioEnum.MoveNext())
            {
                ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();
            }

            return ioEnum.Current;
        }

        private static int GetInt()
        {
            return int.Parse(GetString());
        }

        private static long GetLong()
        {
            return long.Parse(GetString());
        }

        private static double GetDouble()
        {
            return double.Parse(GetString());
        }

        private static List<int> GetIntArr(int n)
        {
            List<int> ret = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                ret.Add(GetInt());
            }
            return ret;
        }

        private static void Wl<T>(T o)
        {
            if (o is double)
            {
                Wld((o as double?).Value, "");
            }
            else if (o is float)
            {
                Wld((o as float?).Value, "");
            }
            else
                Console.WriteLine(o.ToString());
        }

        private static void Wl<T>(IEnumerable<T> enumerable)
        {
            Wl(string.Join(" ", enumerable.Select(e => e.ToString()).ToArray()));
        }

        private static void Wld(double d, string format)
        {
            Wl(d.ToString(format, CultureInfo.InvariantCulture));
        }

        public struct Tuple<T, K> : IComparable<Tuple<T, K>>
            where T : IComparable<T>
            where K : IComparable<K>
        {
            public T Item1;
            public K Item2;

            public Tuple(T t, K k)
            {
                Item1 = t;
                Item2 = k;
            }

            public override bool Equals(object obj)
            {
                var o = (Tuple<T, K>)obj;
                return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);
            }

            public override int GetHashCode()
            {
                return Item1.GetHashCode() ^ Item2.GetHashCode();
            }

            public override string ToString()
            {
                return "(" + Item1 + " " + Item2 + ")";
            }

            #region IComparable<Tuple<T,K>> Members

            public int CompareTo(Tuple<T, K> other)
            {
                int ret = Item1.CompareTo(other.Item1);
                if (ret != 0) return ret;
                return Item2.CompareTo(other.Item2);
            }

            #endregion
        }

        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

namespace Temp
{
    struct PointInt
    {
        public long X;

        public long Y;

        public PointInt(long x, long y)
            : this()
        {
            this.X = x;
            this.Y = y;
        }

        public static PointInt operator +(PointInt a, PointInt b)
        {
            return new PointInt(a.X + b.X, a.Y + b.Y);
        }

        public static PointInt operator -(PointInt a, PointInt b)
        {
            return new PointInt(a.X - b.X, a.Y - b.Y);
        }

        public static PointInt operator *(PointInt a, long k)
        {
            return new PointInt(k * a.X, k * a.Y);
        }

        public static PointInt operator *(long k, PointInt a)
        {
            return new PointInt(k * a.X, k * a.Y);
        }

        public bool IsInsideRectangle(long l, long b, long r, long t)
        {
            return (l <= X) && (X <= r) && (b <= Y) && (Y <= t);
        }
    }

    struct LineInt
    {
        public LineInt(PointInt a, PointInt b)
            : this()
        {
            A = a.Y - b.Y;
            B = b.X - a.X;
            C = a.X * b.Y - a.Y * b.X;
        }

        public long A, B, C;

        public bool ContainsPoint(PointInt p)
        {
            return A * p.X + B * p.Y + C == 0;
        }
    }

    class MatrixInt
    {
        private long[,] m_Matrix;

        public int Size
        {
            get
            {
                return m_Matrix.GetLength(0) - 1;
            }
        }

        public long Mod { get; private set; }

        public MatrixInt(int size, long mod = 0)
        {
            m_Matrix = new long[size + 1, size + 1];
            Mod = mod;
        }

        public MatrixInt(long[,] matrix, long mod = 0)
        {
            this.m_Matrix = matrix;
            Mod = mod;
        }

        public static MatrixInt GetIdentityMatrix(int size, long mod = 0)
        {
            long[,] matrix = new long[size + 1, size + 1];

            for (int i = 1; i <= size; i++)
            {
                matrix[i, i] = 1;
            }

            return new MatrixInt(matrix, mod);
        }

        public long this[int i, int j]
        {
            get
            {
                return m_Matrix[i, j];
            }

            set
            {
                m_Matrix[i, j] = value;
            }
        }

        public static MatrixInt operator +(MatrixInt a, MatrixInt b)
        {
            int n = a.Size;
            long mod = Math.Max(a.Mod, b.Mod);
            long[,] c = new long[n, n];
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    c[i, j] = a[i, j] + b[i, j];
                }
            }

            if (mod > 0)
            {
                for (int i = 1; i <= n; i++)
                {
                    for (int j = 1; j <= n; j++)
                    {
                        c[i, j] %= mod;
                    }
                }
            }

            return new MatrixInt(c, mod);
        }

        public static MatrixInt operator *(MatrixInt a, MatrixInt b)
        {
            int n = a.Size;
            long mod = Math.Max(a.Mod, b.Mod);

            long[,] c = new long[n, n];

            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    for (int k = 1; k <= n; k++)
                    {
                        c[i, j] += a[i, k] * b[k, j];
                        if (mod > 0)
                        {
                            c[i, j] %= mod;
                        }
                    }
                }
            }

            return new MatrixInt(c, mod);
        }
    }

    static class Algebra
    {
        public static long Phi(long n)
        {
            long result = n;
            for (long i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    while (n % i == 0)
                    {
                        n /= i;
                    }

                    result -= result / i;
                }
            }

            if (n > 1)
            {
                result -= result / n;
            }

            return result;
        }

        public static long BinPower(long a, long n, long mod)
        {
            long result = 1;

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result = (result * a) % mod;
                }

                a = (a * a) % mod;
                n >>= 1;
            }

            return result;
        }

        public static class Permutations
        {
            public static int[] GetRandomPermutation(int n)
            {
                int[] p = new int[n];
                for (int i = 0; i < n; i++)
                {
                    p[i] = i;
                }

                Random random = new Random();
                for (int i = n - 1; i > 0; i--)
                {
                    int j = random.Next(i + 1);
                    int tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                }

                return p;
            }
        }

        public static T[] Shuffle<T>(this T[] array)
        {
            int length = array.Length;
            int[] p = Permutations.GetRandomPermutation(length);
            T[] result = new T[length];
            for (int i = 0; i < length; i++)
            {
                result[i] = array[p[i]];
            }

            return result;
        }

        public static MatrixInt MatrixBinPower(MatrixInt a, long n)
        {
            MatrixInt result = new MatrixInt(a.Size);

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result *= a;
                }

                a *= a;
                n >>= 1;
            }

            return result;
        }

        public static long Gcd(long a, long b)
        {
            return b == 0 ? a : Gcd(b, a % b);
        }

        public static long ExtendedGcd(long a, long b, out long x, out long y)
        {
            if (b == 0)
            {
                x = 1;
                y = 0;
                return a;
            }

            long x1;
            long y1;
            long d = ExtendedGcd(b, a % b, out x1, out y1);
            x = y1;
            y = x1 - (a / b) * y1;
            return d;
        }

        public static long Lcm(long a, long b)
        {
            return (a / Gcd(a, b)) * b;
        }

        public static bool[] GetPrimes(int n)
        {
            n = Math.Max(n, 2);
            bool[] prime = new bool[n + 1];
            for (int i = 2; i <= n; i++)
            {
                prime[i] = true;
            }

            for (int i = 2; i * i <= n; i++)
            {
                if (prime[i])
                {
                    if ((long)i * i <= n)
                    {
                        for (int j = i * i; j <= n; j += i)
                        {
                            prime[j] = false;
                        }
                    }
                }
            }

            return prime;
        }

        public static long GetFibonacciNumber(long n, long mod = 0)
        {
            long[,] matrix = new long[,] { { 0, 0, 0 }, { 0, 0, 1 }, { 0, 1, 1 } };

            MatrixInt result = MatrixBinPower(new MatrixInt(matrix, mod), n);

            return result[2, 2];
        }

        public static long[] GetFibonacciSequence(int n)
        {
            long[] result = new long[n];
            result[0] = result[1] = 1;

            for (int i = 2; i < n; i++)
            {
                result[i] = result[i - 1] + result[i - 2];
            }

            return result;
        }

        public static long GetInverseElement(long a, long mod)
        {
            long x, y;
            long g = ExtendedGcd(a, mod, out x, out y);

            if (g != 1)
            {
                return -1;
            }

            return ((x % mod) + mod) % mod;
        }

        public static long[] GetAllInverseElements(long mod)
        {
            long[] result = new long[mod];
            result[1] = 1;
            for (int i = 2; i < mod; i++)
            {
                result[i] = (mod - (((mod / i) * result[mod % i]) % mod)) % mod;
            }

            return result;
        }
    }

    internal static class Reader
    {
        public static void ReadInt(out int a)
        {
            int[] number = new int[1];
            ReadInt(number);
            a = number[0];
        }

        public static void ReadInt(out int a, out int b)
        {
            int[] numbers = new int[2];
            ReadInt(numbers);
            a = numbers[0];
            b = numbers[1];
        }

        public static void ReadInt(out int int1, out int int2, out int int3)
        {
            int[] numbers = new int[3];
            ReadInt(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
        }

        public static void ReadInt(out int int1, out int int2, out int int3, out int int4)
        {
            int[] numbers = new int[4];
            ReadInt(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
            int4 = numbers[3];
        }

        public static void ReadLong(out long a)
        {
            long[] number = new long[1];
            ReadLong(number);
            a = number[0];
        }

        public static void ReadLong(out long a, out long b)
        {
            long[] numbers = new long[2];
            ReadLong(numbers);
            a = numbers[0];
            b = numbers[1];
        }

        public static void ReadLong(out long int1, out long int2, out long int3)
        {
            long[] numbers = new long[3];
            ReadLong(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
        }

        public static void ReadLong(out long int1, out long int2, out long int3, out long int4)
        {
            long[] numbers = new long[4];
            ReadLong(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
            int4 = numbers[3];
        }

        public static void ReadInt(int[] numbers)
        {
            // ReSharper disable PossibleNullReferenceException
            var list = Console.ReadLine().Split();
            // ReSharper restore PossibleNullReferenceException

            int count = Math.Min(numbers.Length, list.Length);

            for (int i = 0; i < count; i++)
            {
                numbers[i] = int.Parse(list[i]);
            }
        }

        public static int[] ReadDigits()
        {
            // ReSharper disable AssignNullToNotNullAttribute
            return Console.ReadLine().Select(x => int.Parse(x.ToString())).ToArray();
            // ReSharper restore AssignNullToNotNullAttribute
        }

        public static void ReadLong(long[] numbers)
        {
            // ReSharper disable PossibleNullReferenceException
            var list = Console.ReadLine().Split();
            // ReSharper restore PossibleNullReferenceException

            int count = Math.Min(numbers.Length, list.Length);

            for (int i = 0; i < count; i++)
            {
                numbers[i] = long.Parse(list[i]);
            }
        }

        public static void ReadDouble(double[] numbers)
        {
            // ReSharper disable PossibleNullReferenceException
            var list = Console.ReadLine().Split();
            // ReSharper restore PossibleNullReferenceException

            int count = Math.Min(numbers.Length, list.Length);

            for (int i = 0; i < count; i++)
            {
                numbers[i] = double.Parse(list[i]);
            }
        }

        public static void ReadDouble(out double a, out double b)
        {
            double[] numbers = new double[2];
            ReadDouble(numbers);
            a = numbers[0];
            b = numbers[1];
        }

        public static void ReadDouble(out double int1, out double int2, out double int3)
        {
            double[] numbers = new double[3];
            ReadDouble(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }
    }

    static class MyMath
    {
        public static int GetMinimalPrimeDivisor(int n)
        {
            for (int i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    return i;
                }
            }

            return n;
        }

        public static long Sqr(long x)
        {
            return x * x;
        }
    }

    public interface IGraph
    {
        int Vertices  { get; set; }

        IList<int> this[int i] { get; }

        void AddEdge(int u, int v);

        void AddOrientedEdge(int u, int v);
    }

    public class Graph : IGraph
    {
        private List<int>[] m_Edges;

        public int Vertices { get; set; }

        public IList<int> this[int i]
        {
            get
            {
                return this.m_Edges[i];
            }
        }

        public Graph(int vertices)
        {
            this.Vertices = vertices;

            this.m_Edges = new List<int>[vertices];

            for (int i = 0; i < vertices; i++)
            {
                this.m_Edges[i] = new List<int>();
            }
        }

        public void AddEdge(int u, int v)
        {
            this.AddOrientedEdge(u, v);
            this.AddOrientedEdge(v, u);
        }

        public void AddOrientedEdge(int first, int second)
        {
            this.m_Edges[first].Add(second);
        }

        public int[] Bfs(int start)
        {
            int[] d = new int[Vertices];
            for (int i = 0; i < Vertices; i++)
            {
                d[i] = -1;
            }

            Queue<int> queue = new Queue<int>();
            queue.Enqueue(start);
            d[start] = 0;

            while (queue.Count > 0)
            {
                int v = queue.Dequeue();
                foreach (int t in this.m_Edges[v].Where(t => d[t] == -1))
                {
                    queue.Enqueue(t);
                    d[t] = d[v] + 1;
                }
            }

            return d;
        }
    }

    class SimpleSumTable
    {
        private readonly int[,] m_Sum;

        public SimpleSumTable(int n, int m, int[,] table)
        {
            m_Sum = new int[n + 1, m + 1];

            for (int i = 1; i < n + 1; i++)
            {
                for (int j = 1; j < m + 1; j++)
                {
                    m_Sum[i, j] = m_Sum[i, j - 1] + m_Sum[i - 1, j] - m_Sum[i - 1, j - 1] + table[i, j];
                }
            }
        }

        public int GetSum(int l, int b, int r, int t)
        {
            return m_Sum[r, t] - m_Sum[r, b] - m_Sum[l, t] + m_Sum[l, b];
        }
    }

    class SegmentTreeSimpleInt<T>
    {
        public int Size { get; private set; }

        private readonly T[] m_Tree;

        private Func<T, T, T> m_Operation;

        private T m_Null;

        public SegmentTreeSimpleInt(int size, Func<T, T, T> operation, T nullElement, IList<T> array = null)
        {
            this.Size = size;
            this.m_Operation = operation;
            this.m_Null = nullElement;

            m_Tree = new T[4 * size];
            if (array != null)
            {
                this.Build(array, 1, 0, size - 1);
            }
        }

        private void Build(IList<T> array, int v, int tl, int tr)
        {
            if (tl == tr)
            {
                m_Tree[v] = array[tl];
            }
            else
            {
                int tm = (tl + tr) / 2;
                this.Build(array, 2 * v, tl, tm);
                this.Build(array, 2 * v + 1, tm + 1, tr);
                this.CalculateNode(v);
            }
        }

        public T GetSum(int l, int r)
        {
            return GetSum(1, 0, Size - 1, l, r);
        }

        private T GetSum(int v, int tl, int tr, int l, int r)
        {
            if (l > r)
            {
                return m_Null;
            }

            if (l == tl && r == tr)
            {
                return m_Tree[v];
            }

            int tm = (tl + tr) / 2;

            return this.m_Operation(GetSum(2 * v, tl, tm, l, Math.Min(r, tm)),GetSum(2 * v + 1, tm + 1, tr, Math.Max(l, tm + 1), r));
        }

        public void Update(int pos, T newValue)
        {
            Update(1, 0, Size - 1, pos, newValue);
        }

        private void Update(int v, int tl, int tr, int pos, T newValue)
        {
            if (tl == tr)
            {
                m_Tree[v] = newValue;
            }
            else
            {
                int tm = (tl + tr) / 2;
                if (pos <= tm)
                {
                    Update(2 * v, tl, tm, pos, newValue);
                }
                else
                {
                    Update(2 * v + 1, tm + 1, tr, pos, newValue);
                }
                this.CalculateNode(v);
            }
        }

        private void CalculateNode(int v)
        {
            m_Tree[v] = this.m_Operation(m_Tree[2 * v], m_Tree[2 * v + 1]);
        }
    }

    struct Pair<TFirst, TSecond>
    {
        public Pair(TFirst first, TSecond second)
            : this()
        {
            this.First = first;
            this.Second = second;
        }

        public TFirst First { set; get; }

        public TSecond Second { set; get; }
    }

    internal class AccumulativeDictionary<TKey> : Dictionary<TKey, int>
    {
        public new void Add(TKey key, int value = 1)
        {
            if (this.ContainsKey(key))
            {
                base[key] += value;
            }
            else
            {
                base.Add(key, value);
            }
        }

        public new int this[TKey key]
        {
            get
            {
                return this.ContainsKey(key) ? base[key] : 0;
            }
            set
            {
                this.Add(key, value);
            }
        }
    }

    class Program
    {
        private static StreamReader m_InputStream;

        private static StreamWriter m_OutStream;

        private static void OpenFiles()
        {
            m_InputStream = File.OpenText("input.txt");
            Console.SetIn(m_InputStream);

            m_OutStream = File.CreateText("output.txt");
            Console.SetOut(m_OutStream);
        }

        private static void CloseFiles()
        {
            m_OutStream.Flush();

            m_InputStream.Dispose();
            m_OutStream.Dispose();
        }

        static void Main()
        {
            //OpenFiles();

            new Solution().Solve();

            //CloseFiles();
        }
    }

    internal class Solution
    {
        public void Solve()
        {
            var t = new AccumulativeDictionary<int>();
            var b = new AccumulativeDictionary<int>();

            int n;
            Reader.ReadInt(out n);
            for (int i = 0; i < n; i++)
            {
                int x, y;
                Reader.ReadInt(out x, out y);

                t.Add(x);
                if (x != y)
                {
                    b.Add(y);
                }
            }

            int ans = -1;
            foreach (var pair in t)
            {
                int sum = pair.Value + b[pair.Key];
                if (2 * sum >= n)
                {
                    if (ans == -1 || ans > (n + 1) / 2 - pair.Value)
                    {
                        ans = (n + 1) / 2 - pair.Value;
                    }
                }
            }

            Console.WriteLine(ans);
        }
    }
}