import java.util.*;

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

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


import java.util.*;

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

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


import java.util.*;

public class D{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[][] card = new int[n][2];
		for(int i = 0; i < n; i++){
			card[i][0] = stdIn.nextInt();
			card[i][1] = stdIn.nextInt();
		}
		int[][] state = new int[100001][2];
		for(int i = 0; i < n; i++){
			state[card[i][0]][0]++;
			state[card[i][1]][1]++;
			if( card[i][0] != card[i][1] ){
				state[card[i][0]][1]++;
			}
		}
		int max = 0;
		for(int i = 1; i < 100001; i++){
			if( state[i][0] > state[max][0] && state[i][1] > n/2 ){
				max = i;
			}
		}
		if( max == 0 ){
			System.out.println(-1);
			return;
		}

		int ans = n/2 + 1 - state[max][0];
		if( ans < 0 ){
			ans = 0;
		}
		System.out.println(ans);
	}
}


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

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

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

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

	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

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

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

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


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

public class D
{
	String line;
	StringTokenizer inputParser;
	BufferedReader is;
	FileInputStream fstream;
	DataInputStream in;

	void openInput(String file)
	{

		if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
		else
		{
			try{

			fstream = new FileInputStream(file);
			in = new DataInputStream(fstream);
			is = new BufferedReader(new InputStreamReader(in));
			}catch(Exception e)
			{
				System.err.println(e);
			}
		}

	}

	void readNextLine()
	{
		try {
			line = is.readLine();
			inputParser = new StringTokenizer(line, " ");
			//System.err.println("Input: " + line);
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	int NextInt()
	{
		String n = inputParser.nextToken();
		int val = Integer.parseInt(n);

		//System.out.println("I read this number: " + val);
		return val;
	}

	String NextString()
	{
		String n = inputParser.nextToken();
		return n;
	}

	void closeInput()
	{
		try {
			is.close();
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	public static void main(String [] argv)
	{
		String filePath=null;
		if(argv.length>0)filePath=argv[0];
		new D(filePath);
	}

	public D(String inputFile)
	{
		openInput(inputFile);

		readNextLine();

		int n=NextInt();

		HashMap<Integer, Integer> hmt = new HashMap<Integer, Integer>();
		HashMap<Integer, Integer> hmb = new HashMap<Integer, Integer>();

		for(int i=0; i<n; i++)
		{
			readNextLine();
			int t=NextInt();
			int b=NextInt();

			if(hmb.containsKey(b))
			{
				hmb.put(b, hmb.get(b)+1);
			}else hmb.put(b, 1);

			if(hmt.containsKey(t))
			{
				hmt.put(t, hmt.get(t)+1);
			}else hmt.put(t, 1);
		}

		int needed=(n+1)/2;

		int ret=Integer.MAX_VALUE;

		TreeSet <Integer> tries= new TreeSet<Integer>();
		tries.addAll(hmt.keySet());
		tries.addAll(hmb.keySet());

		for(int a:tries)
		{
			int done=0;
			if(hmt.containsKey(a))done=hmt.get(a);
			int poss=0;
			if(hmb.containsKey(a))poss=hmb.get(a);
			int need2=needed-done;
			if(poss>=need2)
			{
				ret=Math.min(ret, need2);
			}
		}
		if(ret==Integer.MAX_VALUE)ret=-1;
		System.out.println(ret);

	}

}


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

public class D
{
	String line;
	StringTokenizer inputParser;
	BufferedReader is;
	FileInputStream fstream;
	DataInputStream in;

	void openInput(String file)
	{

		if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
		else
		{
			try{

			fstream = new FileInputStream(file);
			in = new DataInputStream(fstream);
			is = new BufferedReader(new InputStreamReader(in));
			}catch(Exception e)
			{
				System.err.println(e);
			}
		}

	}

	void readNextLine()
	{
		try {
			line = is.readLine();
			inputParser = new StringTokenizer(line, " ");
			//System.err.println("Input: " + line);
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	int NextInt()
	{
		String n = inputParser.nextToken();
		int val = Integer.parseInt(n);

		//System.out.println("I read this number: " + val);
		return val;
	}

	String NextString()
	{
		String n = inputParser.nextToken();
		return n;
	}

	void closeInput()
	{
		try {
			is.close();
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	public static void main(String [] argv)
	{
		String filePath=null;
		if(argv.length>0)filePath=argv[0];
		new D(filePath);
	}

	public D(String inputFile)
	{
		openInput(inputFile);

		readNextLine();

		int n=NextInt();

		HashMap<Integer, Integer> hmt = new HashMap<Integer, Integer>();
		HashMap<Integer, Integer> hmb = new HashMap<Integer, Integer>();
		TreeSet <Integer> tries= new TreeSet<Integer>();
		int needed=(n+1)/2;

		for(int i=0; i<n; i++)
		{
			readNextLine();
			int t=NextInt();
			int b=NextInt();
			if(n<10)
			{
				tries.add(t);
				tries.add(b);
			}
			if(hmt.containsKey(t))
			{
				int cnt=hmt.get(t)+1;
				hmt.put(t, cnt);
				if(cnt>=needed/2)tries.add(t);
			}else hmt.put(t, 1);

			if(t==b)continue;
			if(hmb.containsKey(b))
			{
				int cnt=hmb.get(b)+1;
				hmb.put(b, cnt);
				if(cnt>=needed/2)tries.add(b);
			}else hmb.put(b, 1);
		}

		int ret=Integer.MAX_VALUE;

		for(int a:tries)
		{
			int done=0;
			if(hmt.containsKey(a))done=hmt.get(a);
			int poss=0;
			if(hmb.containsKey(a))poss=hmb.get(a);
			int need2=needed-done;
			need2=Math.max(0, need2);
			if(poss>=need2)
			{
				ret=Math.min(ret, need2);
			}
		}
		if(ret==Integer.MAX_VALUE)ret=-1;
		System.out.println(ret);

	}

}


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

public class D
{
	String line;
	StringTokenizer inputParser;
	BufferedReader is;
	FileInputStream fstream;
	DataInputStream in;

	void openInput(String file)
	{

		if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
		else
		{
			try{

			fstream = new FileInputStream(file);
			in = new DataInputStream(fstream);
			is = new BufferedReader(new InputStreamReader(in));
			}catch(Exception e)
			{
				System.err.println(e);
			}
		}

	}

	void readNextLine()
	{
		try {
			line = is.readLine();
			inputParser = new StringTokenizer(line, " ");
			//System.err.println("Input: " + line);
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	int NextInt()
	{
		String n = inputParser.nextToken();
		int val = Integer.parseInt(n);

		//System.out.println("I read this number: " + val);
		return val;
	}

	String NextString()
	{
		String n = inputParser.nextToken();
		return n;
	}

	void closeInput()
	{
		try {
			is.close();
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	public static void main(String [] argv)
	{
		String filePath=null;
		if(argv.length>0)filePath=argv[0];
		new D(filePath);
	}

	public D(String inputFile)
	{
		openInput(inputFile);

		readNextLine();

		int n=NextInt();

		HashMap<Integer, Integer> hmt = new HashMap<Integer, Integer>();
		HashMap<Integer, Integer> hmb = new HashMap<Integer, Integer>();

		for(int i=0; i<n; i++)
		{
			readNextLine();
			int t=NextInt();
			int b=NextInt();

			if(hmb.containsKey(b))
			{
				hmb.put(b, hmb.get(b)+1);
			}else hmb.put(b, 1);
			if(t==b)continue;
			if(hmt.containsKey(t))
			{
				hmt.put(t, hmt.get(t)+1);
			}else hmt.put(t, 1);
		}

		int needed=(n+1)/2;

		int ret=Integer.MAX_VALUE;

		TreeSet <Integer> tries= new TreeSet<Integer>();
		tries.addAll(hmt.keySet());
		tries.addAll(hmb.keySet());

		for(int a:tries)
		{
			int done=0;
			if(hmt.containsKey(a))done=hmt.get(a);
			int poss=0;
			if(hmb.containsKey(a))poss=hmb.get(a);
			int need2=needed-done;
			if(poss>=need2)
			{
				ret=Math.min(ret, need2);
			}
		}
		if(ret==Integer.MAX_VALUE)ret=-1;
		System.out.println(ret);

	}

}


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

public class D
{
	String line;
	StringTokenizer inputParser;
	BufferedReader is;
	FileInputStream fstream;
	DataInputStream in;

	void openInput(String file)
	{

		if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
		else
		{
			try{

			fstream = new FileInputStream(file);
			in = new DataInputStream(fstream);
			is = new BufferedReader(new InputStreamReader(in));
			}catch(Exception e)
			{
				System.err.println(e);
			}
		}

	}

	void readNextLine()
	{
		try {
			line = is.readLine();
			inputParser = new StringTokenizer(line, " ");
			//System.err.println("Input: " + line);
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	int NextInt()
	{
		String n = inputParser.nextToken();
		int val = Integer.parseInt(n);

		//System.out.println("I read this number: " + val);
		return val;
	}

	String NextString()
	{
		String n = inputParser.nextToken();
		return n;
	}

	void closeInput()
	{
		try {
			is.close();
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	public static void main(String [] argv)
	{
		String filePath=null;
		if(argv.length>0)filePath=argv[0];
		new D(filePath);
	}

	public D(String inputFile)
	{
		openInput(inputFile);

		readNextLine();

		int n=NextInt();

		HashMap<Integer, Integer> hmt = new HashMap<Integer, Integer>();
		HashMap<Integer, Integer> hmb = new HashMap<Integer, Integer>();

		for(int i=0; i<n; i++)
		{
			readNextLine();
			int t=NextInt();
			int b=NextInt();

			if(hmt.containsKey(t))
			{
				hmt.put(t, hmt.get(t)+1);
			}else hmt.put(t, 1);

			if(t==b)continue;
			if(hmb.containsKey(b))
			{
				hmb.put(b, hmb.get(b)+1);
			}else hmb.put(b, 1);
		}

		int needed=(n+1)/2;

		int ret=Integer.MAX_VALUE;

		TreeSet <Integer> tries= new TreeSet<Integer>();
		tries.addAll(hmt.keySet());
		tries.addAll(hmb.keySet());

		for(int a:tries)
		{
			int done=0;
			if(hmt.containsKey(a))done=hmt.get(a);
			int poss=0;
			if(hmb.containsKey(a))poss=hmb.get(a);
			int need2=needed-done;
			need2=Math.max(0, need2);
			if(poss>=need2)
			{
				ret=Math.min(ret, need2);
			}
		}
		if(ret==Integer.MAX_VALUE)ret=-1;
		System.out.println(ret);

	}

}


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

public class D
{
	String line;
	StringTokenizer inputParser;
	BufferedReader is;
	FileInputStream fstream;
	DataInputStream in;

	void openInput(String file)
	{

		if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
		else
		{
			try{

			fstream = new FileInputStream(file);
			in = new DataInputStream(fstream);
			is = new BufferedReader(new InputStreamReader(in));
			}catch(Exception e)
			{
				System.err.println(e);
			}
		}

	}

	void readNextLine()
	{
		try {
			line = is.readLine();
			inputParser = new StringTokenizer(line, " ");
			//System.err.println("Input: " + line);
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	int NextInt()
	{
		String n = inputParser.nextToken();
		int val = Integer.parseInt(n);

		//System.out.println("I read this number: " + val);
		return val;
	}

	String NextString()
	{
		String n = inputParser.nextToken();
		return n;
	}

	void closeInput()
	{
		try {
			is.close();
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	public static void main(String [] argv)
	{
		String filePath=null;
		if(argv.length>0)filePath=argv[0];
		new D(filePath);
	}

	public D(String inputFile)
	{
		openInput(inputFile);

		readNextLine();

		int n=NextInt();

		TreeMap<Integer, Integer> hmt = new TreeMap<Integer, Integer>();
		TreeMap<Integer, Integer> hmb = new TreeMap<Integer, Integer>();
		TreeSet <Integer> tries= new TreeSet<Integer>();
		int needed=(n+1)/2;

		for(int i=0; i<n; i++)
		{
			readNextLine();
			int t=NextInt();
			int b=NextInt();
			if(n<10)
			{
				tries.add(t);
				tries.add(b);
			}
			if(hmt.containsKey(t))
			{
				int cnt=hmt.get(t)+1;
				hmt.put(t, cnt);
				if(cnt>=needed/2)tries.add(t);
			}else hmt.put(t, 1);

			if(t==b)continue;
			if(hmb.containsKey(b))
			{
				int cnt=hmb.get(b)+1;
				hmb.put(b, cnt);
				if(cnt>=needed/2)tries.add(b);
			}else hmb.put(b, 1);
		}

		int ret=Integer.MAX_VALUE;

		for(int a:tries)
		{
			int done=0;
			if(hmt.containsKey(a))done=hmt.get(a);
			int poss=0;
			if(hmb.containsKey(a))poss=hmb.get(a);
			int need2=needed-done;
			need2=Math.max(0, need2);
			if(poss>=need2)
			{
				ret=Math.min(ret, need2);
			}
		}
		if(ret==Integer.MAX_VALUE)ret=-1;
		System.out.println(ret);

	}

}


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

public class D
{
	String line;
	StringTokenizer inputParser;
	BufferedReader is;
	FileInputStream fstream;
	DataInputStream in;

	void openInput(String file)
	{

		if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
		else
		{
			try{

			fstream = new FileInputStream(file);
			in = new DataInputStream(fstream);
			is = new BufferedReader(new InputStreamReader(in));
			}catch(Exception e)
			{
				System.err.println(e);
			}
		}

	}

	void readNextLine()
	{
		try {
			line = is.readLine();
			inputParser = new StringTokenizer(line, " ");
			//System.err.println("Input: " + line);
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	int NextInt()
	{
		String n = inputParser.nextToken();
		int val = Integer.parseInt(n);

		//System.out.println("I read this number: " + val);
		return val;
	}

	String NextString()
	{
		String n = inputParser.nextToken();
		return n;
	}

	void closeInput()
	{
		try {
			is.close();
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	public static void main(String [] argv)
	{
		String filePath=null;
		if(argv.length>0)filePath=argv[0];
		new D(filePath);
	}

	public D(String inputFile)
	{
		openInput(inputFile);

		readNextLine();

		int n=NextInt();

		HashMap<Integer, Integer> hmt = new HashMap<Integer, Integer>();
		HashMap<Integer, Integer> hmb = new HashMap<Integer, Integer>();

		for(int i=0; i<n; i++)
		{
			readNextLine();
			int t=NextInt();
			int b=NextInt();

			if(hmt.containsKey(t))
			{
				hmt.put(t, hmt.get(t)+1);
			}else hmt.put(t, 1);

			if(t==b)continue;
			if(hmb.containsKey(b))
			{
				hmb.put(b, hmb.get(b)+1);
			}else hmb.put(b, 1);
		}

		int needed=(n+1)/2;

		int ret=Integer.MAX_VALUE;

		TreeSet <Integer> tries= new TreeSet<Integer>();
		tries.addAll(hmt.keySet());
		tries.addAll(hmb.keySet());

		for(int a:tries)
		{
			int done=0;
			if(hmt.containsKey(a))done=hmt.get(a);
			int poss=0;
			if(hmb.containsKey(a))poss=hmb.get(a);
			int need2=needed-done;
			if(poss>=need2)
			{
				ret=Math.min(ret, need2);
			}
		}
		if(ret==Integer.MAX_VALUE)ret=-1;
		System.out.println(ret);

	}

}


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

public class D
{
	String line;
	StringTokenizer inputParser;
	BufferedReader is;
	FileInputStream fstream;
	DataInputStream in;

	void openInput(String file)
	{

		if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
		else
		{
			try{

			fstream = new FileInputStream(file);
			in = new DataInputStream(fstream);
			is = new BufferedReader(new InputStreamReader(in));
			}catch(Exception e)
			{
				System.err.println(e);
			}
		}

	}

	void readNextLine()
	{
		try {
			line = is.readLine();
			inputParser = new StringTokenizer(line, " ");
			//System.err.println("Input: " + line);
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	int NextInt()
	{
		String n = inputParser.nextToken();
		int val = Integer.parseInt(n);

		//System.out.println("I read this number: " + val);
		return val;
	}

	String NextString()
	{
		String n = inputParser.nextToken();
		return n;
	}

	void closeInput()
	{
		try {
			is.close();
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	public static void main(String [] argv)
	{
		String filePath=null;
		if(argv.length>0)filePath=argv[0];
		new D(filePath);
	}

	public D(String inputFile)
	{
		openInput(inputFile);

		readNextLine();

		int n=NextInt();

		HashMap<Integer, Integer> hmt = new HashMap<Integer, Integer>();
		HashMap<Integer, Integer> hmb = new HashMap<Integer, Integer>();
		TreeSet <Integer> tries= new TreeSet<Integer>();
		int needed=(n+1)/2;

		for(int i=0; i<n; i++)
		{
			readNextLine();
			int t=NextInt();
			int b=NextInt();
			if(n<10)
			{
				tries.add(t);
				tries.add(b);
			}
			if(hmt.containsKey(t))
			{
				int cnt=hmt.get(t)+1;
				hmt.put(t, cnt);
				if(cnt>=needed/2)tries.add(t);
			}else hmt.put(t, 1);

			if(t==b)continue;
			if(hmb.containsKey(b))
			{
				int cnt=hmb.get(b)+1;
				hmb.put(b, cnt);
				if(cnt>=needed/2)tries.add(t);
			}else hmb.put(b, 1);
		}

		int ret=Integer.MAX_VALUE;

		for(int a:tries)
		{
			int done=0;
			if(hmt.containsKey(a))done=hmt.get(a);
			int poss=0;
			if(hmb.containsKey(a))poss=hmb.get(a);
			int need2=needed-done;
			need2=Math.max(0, need2);
			if(poss>=need2)
			{
				ret=Math.min(ret, need2);
			}
		}
		if(ret==Integer.MAX_VALUE)ret=-1;
		System.out.println(ret);

	}

}


import java.util.*;
import static java.lang.Math.*;
public class ProblemD {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n > 200000) {
            p("Too big!");
            return;
        }
        int half = n/2 + (n % 2);
        int[] top = new int[n];
        int[] bot = new int[n];
        for (int i = 0; i < n; ++i) {
            top[i] = sc.nextInt();
            bot[i] = sc.nextInt();
        }

        // precompute array size
        int[] toporbot; // stores one copy of each colour per card it is on
        int size = n;
        for (int i = 0; i < n; ++i) {
            if (bot[i] != top[i]) {
                ++size;
            }
        }
        int j = 0;
        toporbot = new int[size];
        for (int i = 0; i < n; ++i) {
            toporbot[j] = top[i];
            ++j;
            if (bot[i] != top[i]) {
                toporbot[j] = bot[i];
                ++j;
            }
        }

        Arrays.sort(top);
        Arrays.sort(toporbot);

        int[][] topCounts = countUp(top);
        int[][] toporbotCounts = countUp(toporbot);

        int best = Integer.MAX_VALUE;
        int len = toporbotCounts[0].length;
        j = 0;
        for (int i = 0; i < len; ++i) {
            if (toporbotCounts[1][i] >= half) {
                int topcount = 0;
                if (topCounts[0][j] == toporbotCounts[0][i]) {
                    topcount = topCounts[1][j];
                }
                int val = half - topcount;
                best = min(best, val);
            }
        }

        best = max(best, 0);
        if (best == Integer.MAX_VALUE) {
            best = -1;
        }
        p("%d\n", best);
    }

    int[][] countUp(int[] arr) {
        // precompute array size
        int[][] res;
        int size = 0;
        int curr = -1;
        for (int color : arr) {
            if (curr != color) {
                curr = color;
                ++size;
            }
        }

        res = new int[2][size];
        int i = -1;
        curr = -1;
        int count = -1;
        for (int color : arr) {
            if (curr != color) {
                if (i >= 0) {
                    res[0][i] = curr;
                    res[1][i] = count;
                }
                curr = color;
                count = 0;
                ++i;
            }
            else {
                ++count;
            }
        }

        return res;
    }

    void increment(Map<Integer, Integer> counts, int x) {
        if (counts.containsKey(x)) {
            counts.put(x, counts.get(x) + 1);
        }
        else {
            counts.put(x, 1);
        }
    }

    boolean debug = false;
    void p(String f, Object...params) {
        System.out.printf(f, params);
    }
    void d(Object...params) {
        if (debug) {
            p("DEBUG: %s\n", Arrays.deepToString(params));
        }
    }
    public ProblemD(String[] args) {
        if (args.length > 0 && args[0].equals("debug")) {
            debug = true;
        }
    }
    public static void main(String[] args) {
        new ProblemD(args).run();
    }
}


import java.util.*;
import static java.lang.Math.*;
public class ProblemD {
    void run() {
        if (debug) {
            System.out.println("Debug!");
        }
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n > 200000) {
            p("Too big!");
            return;
        }
        int half = n/2 + (n % 2);
        int[] top = new int[n];
        int[] bot = new int[n];
        for (int i = 0; i < n; ++i) {
            top[i] = sc.nextInt();
            bot[i] = sc.nextInt();
        }

        // precompute array size
        int[] toporbot; // stores one copy of each colour per card it is on
        int size = n;
        for (int i = 0; i < n; ++i) {
            if (bot[i] != top[i]) {
                ++size;
            }
        }
        int j = 0;
        toporbot = new int[size];
        for (int i = 0; i < n; ++i) {
            toporbot[j] = top[i];
            ++j;
            if (bot[i] != top[i]) {
                toporbot[j] = bot[i];
                ++j;
            }
        }

        Arrays.sort(top);
        Arrays.sort(toporbot);

        int[][] topCounts = countUp(top);
        int[][] toporbotCounts = countUp(toporbot);

        int best = Integer.MAX_VALUE;
        int len = toporbotCounts[0].length;
        j = 0;
        for (int i = 0; i < len; ++i) {
            while (j < topCounts[0].length && topCounts[0][j] < toporbotCounts[0][i]) {
                ++j;
            }
            if (toporbotCounts[1][i] >= half) {
                int topcount = 0;
                if (j < topCounts[0].length && topCounts[0][j] == toporbotCounts[0][i]) {
                    topcount = topCounts[1][j];
                }
                int val = half - topcount;
                best = min(best, val);
            }
        }

        best = max(best, 0);
        if (best == Integer.MAX_VALUE) {
            best = -1;
        }
        p("%d\n", best);
    }

    int[][] countUp(int[] arr) {
        // precompute array size
        int[][] res;
        int size = 0;
        int curr = -1;
        for (int color : arr) {
            if (curr != color) {
                curr = color;
                ++size;
            }
        }

        res = new int[2][size];
        int i = -1;
        curr = -1;
        int count = -1;
        for (int color : arr) {
            if (curr != color) {
                if (i >= 0) {
                    res[0][i] = curr;
                    res[1][i] = count;
                }
                curr = color;
                count = 1;
                ++i;
            }
            else {
                ++count;
            }
        }
        res[0][i] = curr;
        res[1][i] = count;

        return res;
    }

    void increment(Map<Integer, Integer> counts, int x) {
        if (counts.containsKey(x)) {
            counts.put(x, counts.get(x) + 1);
        }
        else {
            counts.put(x, 1);
        }
    }

    boolean debug = false;
    void p(String f, Object...params) {
        System.out.printf(f, params);
    }
    void d(Object...params) {
        if (debug) {
            p("DEBUG: %s\n", Arrays.deepToString(params));
        }
    }
    public ProblemD(String[] args) {
        if (args.length > 0 && args[0].equals("debug")) {
            debug = true;
        }
    }
    public static void main(String[] args) {
        new ProblemD(args).run();
    }
}


import java.util.*;
import static java.lang.Math.*;
public class ProblemD {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int half = n/2 + (n % 2);
        int[] top = new int[n];
        int[] bot = new int[n];
        for (int i = 0; i < n; ++i) {
            top[i] = sc.nextInt();
            bot[i] = sc.nextInt();
        }
        Map<Integer, Integer> counts = new HashMap<Integer, Integer>();
        for (int i = 0; i < n; ++i) {
            increment(counts, top[i]);
            if (bot[i] != top[i]) {
                increment(counts, bot[i]);
            }
        }
        int best = Integer.MAX_VALUE;
        List<Integer> todo = new ArrayList<Integer>();
        for (int x : top) {
            if (counts.get(x) >= half && !todo.contains(x)) {
                todo.add(x);
            }
        }
        for (int x : bot) {
            if (counts.get(x) >= half && !todo.contains(x)) {
                todo.add(x);
            }
        }
        for (int x : todo) {
            int topCount = 0;
            for (int y : top) {
                if (y == x) {
                    ++topCount;
                }
            }
            best = min(best, half - topCount);
        }
        best = max(best, 0);
        if (best == Integer.MAX_VALUE) {
            best = -1;
        }
        p("%d\n", best);
    }

    void increment(Map<Integer, Integer> counts, int x) {
        if (counts.containsKey(x)) {
            counts.put(x, counts.get(x) + 1);
        }
        else {
            counts.put(x, 1);
        }
    }

    boolean debug = false;
    void p(String f, Object...params) {
        System.out.printf(f, params);
    }
    void d(Object...params) {
        if (debug) {
            p("DEBUG: %s\n", Arrays.deepToString(params));
        }
    }
    public ProblemD(String[] args) {
        if (args.length > 0 && args[0].equals("debug")) {
            debug = true;
        }
    }
    public static void main(String[] args) {
        new ProblemD(args).run();
    }
}


import java.util.*;
import static java.lang.Math.*;
public class ProblemD {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n > 200000) {
            p("Too big!");
            return;
        }
        int half = n/2 + (n % 2);
        int[] top = new int[n];
        int[] bot = new int[n];
        for (int i = 0; i < n; ++i) {
            top[i] = sc.nextInt();
            bot[i] = sc.nextInt();
        }
        Map<Integer, Integer> counts = new HashMap<Integer, Integer>();
        for (int i = 0; i < n; ++i) {
            increment(counts, top[i]);
            if (bot[i] != top[i]) {
                increment(counts, bot[i]);
            }
        }
        int best = Integer.MAX_VALUE;
        List<Integer> todo = new ArrayList<Integer>();
        for (int x : top) {
            if (counts.get(x) >= half && !todo.contains(x)) {
                todo.add(x);
            }
        }
        for (int x : bot) {
            if (counts.get(x) >= half && !todo.contains(x)) {
                todo.add(x);
            }
        }
        for (int x : todo) {
            int topCount = 0;
            for (int y : top) {
                if (y == x) {
                    ++topCount;
                }
            }
            best = min(best, half - topCount);
        }
        best = max(best, 0);
        if (best == Integer.MAX_VALUE) {
            best = -1;
        }
        p("%d\n", best);
    }

    void increment(Map<Integer, Integer> counts, int x) {
        if (counts.containsKey(x)) {
            counts.put(x, counts.get(x) + 1);
        }
        else {
            counts.put(x, 1);
        }
    }

    boolean debug = false;
    void p(String f, Object...params) {
        System.out.printf(f, params);
    }
    void d(Object...params) {
        if (debug) {
            p("DEBUG: %s\n", Arrays.deepToString(params));
        }
    }
    public ProblemD(String[] args) {
        if (args.length > 0 && args[0].equals("debug")) {
            debug = true;
        }
    }
    public static void main(String[] args) {
        new ProblemD(args).run();
    }
}


import java.util.*;
import static java.lang.Math.*;
public class ProblemD {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int half = n/2 + (n % 2);
        int[] top = new int[n];
        int[] bot = new int[n];
        for (int i = 0; i < n; ++i) {
            top[i] = sc.nextInt();
            bot[i] = sc.nextInt();
        }
        Map<Integer, Integer> counts = new HashMap<Integer, Integer>();
        for (int i = 0; i < n; ++i) {
            increment(counts, top[i]);
            if (bot[i] != top[i]) {
                increment(counts, bot[i]);
            }
        }
        int best = Integer.MAX_VALUE;
        for (int x : counts.keySet()) {
            if (counts.get(x) >= half) {
                int topCount = 0;
                for (int y : top) {
                    if (y == x) {
                        ++topCount;
                    }
                }
                best = min(best, half - topCount);
            }
        }
        best = max(best, 0);
        if (best == Integer.MAX_VALUE) {
            best = -1;
        }
        p("%d\n", best);
    }

    void increment(Map<Integer, Integer> counts, int x) {
        if (counts.containsKey(x)) {
            counts.put(x, counts.get(x) + 1);
        }
        else {
            counts.put(x, 1);
        }
    }

    boolean debug = false;
    void p(String f, Object...params) {
        System.out.printf(f, params);
    }
    void d(Object...params) {
        if (debug) {
            p("DEBUG: %s\n", Arrays.deepToString(params));
        }
    }
    public ProblemD(String[] args) {
        if (args.length > 0 && args[0].equals("debug")) {
            debug = true;
        }
    }
    public static void main(String[] args) {
        new ProblemD(args).run();
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        HashMap<Integer, Color> map = new HashMap<Integer, Color>();

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int idx = str.indexOf(' ');

            int f = Integer.parseInt(str.substring(0, idx));
            if (!map.containsKey(f)) {
                map.put(f, new Color());
            }
            map.get(f).fn++;

            int b = Integer.parseInt(str.substring(idx + 1));
            if (!map.containsKey(b)) {
                map.put(b, new Color());
            }
            if (f != b) {
                map.get(b).bn++;
            }
        }

        long min = Long.MAX_VALUE;
        for (Integer it : map.keySet()) {
            Color c = map.get(it);
            if (c.fn + c.bn >= (n + 1) / 2) {
                min = Math.min(min, Math.max(0, (n + 1) / 2 - c.fn));
            }
        }
        if (min == Long.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
    class Color {
        int fn = 0;
        int bn = 0;
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        HashMap<Integer, Color> map = new HashMap<Integer, Color>();

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int idx = str.indexOf(' ');

            int f = Integer.parseInt(str.substring(0, idx));
            if (!map.containsKey(f)) {
                map.put(f, new Color());
            }
            map.get(f).fn++;

            int b = Integer.parseInt(str.substring(idx + 1));
            if (!map.containsKey(b)) {
                map.put(b, new Color());
            }
            if (f != b) {
                map.get(b).bn++;
            }
        }

        long min = Long.MAX_VALUE;
        for (Color c : map.values()) {
            if (c.fn + c.bn >= (n + 1) / 2) {
                min = Math.min(min, Math.max(0, (n + 1) / 2 - c.fn));
            }
        }
        if (min == Long.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
    class Color {
        int fn = 0;
        int bn = 0;
    }
}


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

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

    //
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        HashMap<Integer, Long> map = new HashMap<Integer, Long>();

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int idx = str.indexOf(' ');

            int f = Integer.parseInt(str.substring(0, idx));
            if (!map.containsKey(f)) {
                map.put(f, 0L);
            }
            map.put(f, map.get(f) + Integer.MAX_VALUE);

            int b = Integer.parseInt(str.substring(idx + 1));
            if (!map.containsKey(b)) {
                map.put(b, 0L);
            }
            if (f != b) {
                map.put(b, map.get(b) + 1);
            }
        }

        long min = Long.MAX_VALUE;
        for (Long l : map.values()) {
            int fn = (int) (l / Integer.MAX_VALUE);
            int bn = (int) (l % Integer.MAX_VALUE);
            if (fn + bn >= (n + 1) / 2) {
                min = Math.min(min, Math.max(0, (n + 1) / 2 - fn));
                return;
            }
        }
        if (min == Long.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    int n;
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        // BufferedReader in = new BufferedReader(new
        // InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(n * 2);
        int[] fn = new int[2 * n];
        int[] bn = new int[2 * n];
        int size = 0;

        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int f = sc.nextInt();
            {// fi
                if (!map.containsKey(f) && i <= (n + 1) / 2) {
                    map.put(f, size++);
                }
                Integer fi;
                if (null != (fi = map.get(f))) {
                    fn[fi]++;
                    if (fn[fi] + bn[fi] >= (n + 1) / 2) {
                        min = Math.min(min, Math.max(0, (n + 1) / 2 - fn[fi]));
                    }
                }
            }

            int b = sc.nextInt();
            {// bi
                if (!map.containsKey(b) && i <= (n + 1) / 2) {
                    map.put(b, size++);
                }
                Integer bi;
                if (f != b && (null != (bi = map.get(b)))) {
                    bn[bi]++;
                    if (fn[bi] + bn[bi] >= (n + 1) / 2) {
                        min = Math.min(min, Math.max(0, (n + 1) / 2 - fn[bi]));
                    }
                }
            }
        }
        if (min == Integer.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
    // class Color {
    // int fn = 0;
    // int bn = 0;
    // }

}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    int n;
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        // BufferedReader in = new BufferedReader(new
        // InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        HashMap<Integer, Color> map = new HashMap<Integer, Color>();

        int min = Integer.MAX_VALUE;
        for (int i = 0; map.size() <= n / 2 + 2 && i < n; i++) {
            int f = sc.nextInt();
            if (!map.containsKey(f)) {
                map.put(f, new Color());
            }
            Color cf = map.get(f);
            cf.fn++;
            if (cf.fn + cf.bn >= (n + 1) / 2) {
                min = Math.min(min, Math.max(0, (n + 1) / 2 - cf.fn));
            }

            int b = sc.nextInt();
            if (!map.containsKey(b)) {
                map.put(b, new Color());
            }
            if (f != b) {
                Color cb = map.get(b);
                cb.bn++;
                if (cb.fn + cb.bn >= (n + 1) / 2) {
                    min = Math.min(min, Math.max(0, (n + 1) / 2 - cb.fn));
                }
            }
        }
        if (min == Integer.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
    class Color {
        int fn = 0;
        int bn = 0;
    }

}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    int n;
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        n = Integer.parseInt(in.readLine());
        HashMap<Integer, Color> map = new HashMap<Integer, Color>();

        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int idx = str.indexOf(' ');

            int f = Integer.parseInt(str.substring(0, idx));
            if (!map.containsKey(f)) {
                map.put(f, new Color());
            }
            Color cf = map.get(f);
            cf.fn++;
            if (cf.fn + cf.bn >= (n + 1) / 2) {
                min = Math.min(min, Math.max(0, (n + 1) / 2 - cf.fn));
            }

            int b = Integer.parseInt(str.substring(idx + 1));
            if (!map.containsKey(b)) {
                map.put(b, new Color());
            }
            if (f != b) {
                Color cb = map.get(b);
                cb.bn++;
                if (cb.fn + cb.bn >= (n + 1) / 2) {
                    min = Math.min(min, Math.max(0, (n + 1) / 2 - cb.fn));
                }
            }
        }
        if (min == Integer.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
    class Color {
        int fn = 0;
        int bn = 0;
    }

}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        long[] color = new long[2 * n];
        int size = 0;

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int idx = str.indexOf(' ');

            int f = Integer.parseInt(str.substring(0, idx));
            if (!map.containsKey(f)) {
                map.put(f, size++);
            }
            color[map.get(f)] += Integer.MAX_VALUE;

            int b = Integer.parseInt(str.substring(idx + 1));
            if (!map.containsKey(b)) {
                map.put(b, size++);
            }
            if (f != b) {
                color[map.get(b)]++;
            }
        }
        Arrays.sort(color, 0, size);

        for (int i = size; i >= 0; i--) {
            int fn = (int) (color[i] / Integer.MAX_VALUE);
            int bn = (int) (color[i] % Integer.MAX_VALUE);
            if (fn + bn >= (n + 1) / 2) {
                System.out.println(Math.max(0, (n + 1) / 2 - fn));
                return;
            }
        }
        System.out.println("-1");
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        Map<Integer, Integer> map = new HashMap<Integer, Integer>(4*n);
        int[] fn = new int[4 * n];
        int[] bn = new int[4 * n];
        int size = 0;

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int f, b;
            int idx = str.indexOf(' ');
            f = Integer.parseInt(str.substring(0, idx));
            b = Integer.parseInt(str.substring(idx + 1));
            {// fi
                if (!map.containsKey(f) && i <= (n + 1) / 2) {
                    map.put(f, size++);
                }
                Integer fi;
                if (null != (fi = map.get(f))) {
                    fn[fi]++;
                }
            }
            {// bi
                if (!map.containsKey(b) && i <= (n + 1) / 2) {
                    map.put(b, size++);
                }
                Integer bi;
                if (f != b && (null != (bi = map.get(b)))) {
                    bn[bi]++;
                }
            }
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < size; i++) {
            if (fn[i] + bn[i] >= (n + 1) / 2) {
                min = Math.min(min, Math.max(0, (n + 1) / 2 - fn[i]));
            }
        }
        if (min == Integer.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(n * 3, 1.0f);
        int[] fn = new int[2 * n];
        int[] bn = new int[2 * n];
        int size = 0;

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int f, b;
            int idx = str.indexOf(' ');
            f = Integer.parseInt(str.substring(0, idx));
            b = Integer.parseInt(str.substring(idx + 1));
            {// fi
                if (!map.containsKey(f) && i <= (n + 1) / 2) {
                    map.put(f, size++);
                }
                Integer fi;
                if (null != (fi = map.get(f))) {
                    fn[fi]++;
                }
            }
            {// bi
                if (!map.containsKey(b) && i <= (n + 1) / 2) {
                    map.put(b, size++);
                }
                Integer bi;
                if (f != b && (null != (bi = map.get(b)))) {
                    bn[bi]++;
                }
            }
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < size; i++) {
            if (fn[i] + bn[i] >= (n + 1) / 2) {
                min = Math.min(min, Math.max(0, (n + 1) / 2 - fn[i]));
            }
        }
        if (min == Integer.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    int n;
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        // BufferedReader in = new BufferedReader(new
        // InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(n * 2);
        int[] fn = new int[2 * n];
        int[] bn = new int[2 * n];
        int size = 0;

        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int f = sc.nextInt();
            {// fi
                if (!map.containsKey(f)) {
                    map.put(f, size++);
                }
                int fi = map.get(f);
                fn[fi]++;
                if (fn[fi] + bn[fi] >= (n + 1) / 2) {
                    min = Math.min(min, Math.max(0, (n + 1) / 2 - fn[fi]));
                }
            }
            int b = sc.nextInt();
            {// bi
                if (!map.containsKey(b)) {
                    map.put(b, size++);
                }
                if (f != b) {
                    int bi = map.get(b);
                    bn[bi]++;
                    if (fn[bi] + bn[bi] >= (n + 1) / 2) {
                        min = Math.min(min, Math.max(0, (n + 1) / 2 - fn[bi]));
                    }
                }
            }
        }
        if (min == Integer.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
    // class Color {
    // int fn = 0;
    // int bn = 0;
    // }

}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        long[] color = new long[2 * n];
        int size = 0;

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int idx = str.indexOf(' ');

            int f = Integer.parseInt(str.substring(0, idx));
            if (!map.containsKey(f)) {
                map.put(f, size++);
            }
            color[map.get(f)] += Integer.MAX_VALUE;

            int b = Integer.parseInt(str.substring(idx + 1));
            if (!map.containsKey(b)) {
                map.put(b, size++);
            }
            if (f != b) {
                color[map.get(b)]++;
            }
        }
        Arrays.sort(color, 0, size);

        for (int i = size-1; i >= 0; i--) {
            int fn = (int) (color[i] / Integer.MAX_VALUE);
            int bn = (int) (color[i] % Integer.MAX_VALUE);
            if (fn + bn >= (n + 1) / 2) {
                System.out.println((n + 1) / 2 - fn);
                return;
            }
        }
        System.out.println("-1");
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
        int[] fn = new int[2 * n];
        int[] bn = new int[2 * n];
        int size = 0;

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int f, b;
            int idx = str.indexOf(' ');
            f = Integer.parseInt(str.substring(0, idx));
            b = Integer.parseInt(str.substring(idx + 1));
            {// fi
                if (!map.containsKey(f) && i <= (n + 1) / 2) {
                    map.put(f, size++);
                }
                Integer fi;
                if (null != (fi = map.get(f))) {
                    fn[fi]++;
                }
            }
            {// bi
                if (!map.containsKey(b) && i <= (n + 1) / 2) {
                    map.put(b, size++);
                }
                Integer bi;
                if (f != b && (null != (bi = map.get(b)))) {
                    bn[bi]++;
                }
            }
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < size; i++) {
            if (fn[i] + bn[i] >= (n + 1) / 2) {
                min = Math.min(min, Math.max(0, (n + 1) / 2 - fn[i]));
            }
        }
        if (min == Integer.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        long[] color = new long[2 * n];
        int size = 0;

        long max = 0;
        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int idx = str.indexOf(' ');

            int f = Integer.parseInt(str.substring(0, idx));
            if (!map.containsKey(f)) {
                map.put(f, size++);
            }
            int fi = map.get(f);
            color[fi] += Integer.MAX_VALUE;
            max = Math.max(max, (color[fi] / Integer.MAX_VALUE + color[fi] % Integer.MAX_VALUE));

            int b = Integer.parseInt(str.substring(idx + 1));
            if (!map.containsKey(b)) {
                map.put(b, size++);
            }
            if (f != b) {
                int bi = map.get(b);
                color[bi]++;
                max = Math.max(max, (color[bi] / Integer.MAX_VALUE + color[bi] % Integer.MAX_VALUE));
            }
        }
        if (max < (n + 1) / 2) {
            System.out.println("-1");
        }

        Arrays.sort(color, 0, size);
        for (int i = size - 1; i >= 0; i--) {
            int fn = (int) (color[i] / Integer.MAX_VALUE);
            int bn = (int) (color[i] % Integer.MAX_VALUE);
            if (fn + bn >= (n + 1) / 2) {
                System.out.println(Math.max(0, (n + 1) / 2 - fn));
                return;
            }
        }
        System.out.println("-1");
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        int[] fn = new int[4 * n];
        int[] bn = new int[4 * n];
        int size = 0;

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int f, b;
            int idx = str.indexOf(' ');
            f = Integer.parseInt(str.substring(0, idx));
            b = Integer.parseInt(str.substring(idx + 1));
            {// fi
                if (!map.containsKey(f) && i <= (n + 1) / 2) {
                    map.put(f, size++);
                }
                Integer fi;
                if (null != (fi = map.get(f))) {
                    fn[fi]++;
                }
            }
            {// bi
                if (!map.containsKey(b) && i <= (n + 1) / 2) {
                    map.put(b, size++);
                }
                Integer bi;
                if (f != b && (null != (bi = map.get(b)))) {
                    bn[bi]++;
                }
            }
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < size; i++) {
            if (fn[i] + bn[i] >= (n + 1) / 2) {
                min = Math.min(min, Math.max(0, (n + 1) / 2 - fn[i]));
            }
        }
        if (min == Integer.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        HashMap<Integer, Color> map = new HashMap<Integer, Color>();

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int idx = str.indexOf(' ');

            int f = Integer.parseInt(str.substring(0, idx));
            if (!map.containsKey(f)) {
                map.put(f, new Color());
            }
            map.get(f).fn++;

            int b = Integer.parseInt(str.substring(idx + 1));
            if (!map.containsKey(b)) {
                map.put(b, new Color());
            }
            if (f != b) {
                map.get(b).bn++;
            }
        }

        Color[] color = new Color[map.size()];
        int size = 0;
        for (int i : map.keySet()) {
            color[size++] = map.get(i);
        }
        Arrays.sort(color);

        for (int i = 0; i < size; i++) {
            if (color[i].fn + color[i].bn >= (n + 1) / 2) {
                int r = Math.max(0, (n + 1) / 2 - color[i].fn);
                System.out.println(r);
                return;
            }
        }
        System.out.println("-1");
    }
    class Color implements Comparable<Color> {
        int fn = 0;
        int bn = 0;
        @Override
        public int compareTo(Color c) {
            if (fn != c.fn) {
                return -(fn - c.fn);
            } else {// ==
                return -(bn - c.bn);
            }
        }
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        HashMap<Integer, Color> map = new HashMap<Integer, Color>();

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int idx = str.indexOf(' ');

            int f = Integer.parseInt(str.substring(0, idx));
            if (!map.containsKey(f)) {
                map.put(f, new Color());
            }
            Color cf = map.get(f);
            cf.fn++;

            int b = Integer.parseInt(str.substring(idx + 1));
            if (!map.containsKey(b)) {
                map.put(b, new Color());
            }
            Color cb = map.get(b);
            cb.bn++;
        }

        Color[] color = new Color[map.size()];
        int size = 0;
        for (int i : map.keySet()) {
            color[size++] = map.get(i);
        }
        Arrays.sort(color);

        for (int i = 0; i < size; i++) {
            if (color[i].fn + color[i].bn >= (n + 1) / 2) {
                int r = Math.max(0, (n + 1) / 2 - color[i].fn);
                System.out.println(r);
                return;
            }
        }
        System.out.println("-1");

    }
    // 表多い順ソート、
    // 表同じなら裏多い順ソート
    class Color implements Comparable<Color> {
        int fn;
        int bn;
        @Override
        public int compareTo(Color c) {
            if (fn != c.fn) {
                return -(fn - c.fn);
            } else {// ==
                return -(bn - c.bn);
            }
        }
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>(n * 3, 1.0f);
        int[] fn = new int[2 * n];
        int[] bn = new int[2 * n];
        int size = 0;

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int f, b;
            int idx = str.indexOf(' ');
            f = Integer.parseInt(str.substring(0, idx));
            b = Integer.parseInt(str.substring(idx + 1));
            {// fi
                if (!map.containsKey(f) && i <= (n + 1) / 2) {
                    map.put(f, size++);
                }
                Integer fi;
                if (null != (fi = map.get(f))) {
                    fn[fi]++;
                }
            }
            {// bi
                if (!map.containsKey(b) && i <= (n + 1) / 2) {
                    map.put(b, size++);
                }
                Integer bi;
                if (f != b && (null != (bi = map.get(b)))) {
                    bn[bi]++;
                }
            }
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < size; i++) {
            if (fn[i] + bn[i] >= (n + 1) / 2) {
                min = Math.min(min, Math.max(0, (n + 1) / 2 - fn[i]));
            }
        }
        if (min == Integer.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        Map<Integer, Integer> map = new HashMap<Integer, Integer>(4 * n * 4 / 3 + 1);
        int[] fn = new int[4 * n];
        int[] bn = new int[4 * n];
        int size = 0;

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int f, b;
            int idx = str.indexOf(' ');
            f = Integer.parseInt(str.substring(0, idx));
            b = Integer.parseInt(str.substring(idx + 1));
            {// fi
                if (!map.containsKey(f) && i <= (n + 1) / 2) {
                    map.put(f, size++);
                }
                Integer fi;
                if (null != (fi = map.get(f))) {
                    fn[fi]++;
                }
            }
            {// bi
                if (!map.containsKey(b) && i <= (n + 1) / 2) {
                    map.put(b, size++);
                }
                Integer bi;
                if (f != b && (null != (bi = map.get(b)))) {
                    bn[bi]++;
                }
            }
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < size; i++) {
            if (fn[i] + bn[i] >= (n + 1) / 2) {
                min = Math.min(min, Math.max(0, (n + 1) / 2 - fn[i]));
            }
        }
        if (min == Integer.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    int n;
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        // BufferedReader in = new BufferedReader(new
        // InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        HashMap<Integer, Color> map = new HashMap<Integer, Color>();

        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int f = sc.nextInt();
            if (!map.containsKey(f)) {
                map.put(f, new Color());
            }
            Color cf = map.get(f);
            cf.fn++;
            if (cf.fn + cf.bn >= (n + 1) / 2) {
                min = Math.min(min, Math.max(0, (n + 1) / 2 - cf.fn));
            }

            int b = sc.nextInt();
            if (!map.containsKey(b)) {
                map.put(b, new Color());
            }
            if (f != b) {
                Color cb = map.get(b);
                cb.bn++;
                if (cb.fn + cb.bn >= (n + 1) / 2) {
                    min = Math.min(min, Math.max(0, (n + 1) / 2 - cb.fn));
                }
            }
        }
        if (min == Integer.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
    class Color {
        int fn = 0;
        int bn = 0;
    }

}


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

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

    @SuppressWarnings("boxing")
    void solve() throws IOException {
        int of = (int) (System.currentTimeMillis() % 100000) + 1234;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        Map<Integer, Integer> map = new HashMap<Integer, Integer>(256);
        int[] fn = new int[4 * n];
        int[] bn = new int[4 * n];
        int size = 0;

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int f, b;
            int idx = str.indexOf(' ');
            f = Integer.parseInt(str.substring(0, idx)) + of;
            b = Integer.parseInt(str.substring(idx + 1)) + of;
            {// fi
                if (!map.containsKey(f) && i <= (n + 1) / 2) {
                    map.put(f, size++);
                }
                Integer fi;
                if (null != (fi = map.get(f))) {
                    fn[fi]++;
                }
            }
            {// bi
                if (!map.containsKey(b) && i <= (n + 1) / 2) {
                    map.put(b, size++);
                }
                Integer bi;
                if (f != b && (null != (bi = map.get(b)))) {
                    bn[bi]++;
                }
            }
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < size; i++) {
            if (fn[i] + bn[i] >= (n + 1) / 2) {
                min = Math.min(min, Math.max(0, (n + 1) / 2 - fn[i]));
            }
        }
        if (min == Integer.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
}


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

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

    //
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        HashMap<Integer, Long> map = new HashMap<Integer, Long>();

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int idx = str.indexOf(' ');

            int f = Integer.parseInt(str.substring(0, idx));
            if (!map.containsKey(f)) {
                map.put(f, 0L);
            }
            map.put(f, map.get(f) + Integer.MAX_VALUE);

            int b = Integer.parseInt(str.substring(idx + 1));
            if (!map.containsKey(b)) {
                map.put(b, 0L);
            }
            if (f != b) {
                map.put(b, map.get(b) + 1);
            }
        }

        long min = Long.MAX_VALUE;
        for (Long l : map.values()) {
            int fn = (int) (l / Integer.MAX_VALUE);
            int bn = (int) (l % Integer.MAX_VALUE);
            if (fn + bn >= (n + 1) / 2) {
                min = Math.min(min, Math.max(0, (n + 1) / 2 - fn));
            };
        }
        if (min == Long.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        long[] color = new long[2 * n];
        int size = 0;

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int idx = str.indexOf(' ');

            int f = Integer.parseInt(str.substring(0, idx));
            if (!map.containsKey(f)) {
                map.put(f, size++);
            }
            color[map.get(f)] += Integer.MAX_VALUE;

            int b = Integer.parseInt(str.substring(idx + 1));
            if (!map.containsKey(b)) {
                map.put(b, size++);
            }
            if (f != b) {
                color[map.get(b)]++;
            }
        }
        Arrays.sort(color, 0, size);

        for (int i = size - 1; i >= 0; i--) {
            int fn = (int) (color[i] / Integer.MAX_VALUE);
            int bn = (int) (color[i] % Integer.MAX_VALUE);
            if (fn + bn >= (n + 1) / 2) {
                System.out.println(Math.max(0, (n + 1) / 2 - fn));
                return;
            }
        }
        System.out.println("-1");
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        HashMap<Integer, Color> map = new HashMap<Integer, Color>();

        int cmax = 0;
        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int idx = str.indexOf(' ');

            int f = Integer.parseInt(str.substring(0, idx));
            if (!map.containsKey(f)) {
                map.put(f, new Color());
            }
            Color cf = map.get(f);
            cf.fn++;
            cmax = Math.max(cmax, cf.fn + cf.bn);

            int b = Integer.parseInt(str.substring(idx + 1));
            if (!map.containsKey(b)) {
                map.put(b, new Color());
            }
            if (f != b) {
                Color cb = map.get(b);
                cb.bn++;
                cmax = Math.max(cmax, cb.fn + cb.bn);
            }
        }

        long min = Long.MAX_VALUE;
        if (cmax >= (n + 1) / 2) {
            for (Integer it : map.keySet()) {
                Color c = map.get(it);
                if (c.fn + c.bn >= (n + 1) / 2) {
                    min = Math.min(min, Math.max(0, (n + 1) / 2 - c.fn));
                }
            }
        }
        if (min == Long.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
    class Color {
        int fn = 0;
        int bn = 0;
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        long[] color = new long[2 * n];
        int size = 0;

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int idx = str.indexOf(' ');

            int f = Integer.parseInt(str.substring(0, idx));
            if (!map.containsKey(f)) {
                map.put(f, size++);
            }
            color[map.get(f)] += Integer.MAX_VALUE;

            int b = Integer.parseInt(str.substring(idx + 1));
            if (!map.containsKey(b)) {
                map.put(b, size++);
            }
            if (f != b) {
                color[map.get(b)]++;
            }
        }
        Arrays.sort(color, 0, size);

        for (int i = size; i >= 0; i--) {
            int fn = (int) (color[i] / Integer.MAX_VALUE);
            int bn = (int) (color[i] % Integer.MAX_VALUE);
            if (fn + bn >= (n + 1) / 2) {
                System.out.println((n + 1) / 2 - fn);
                return;
            }
        }
        System.out.println("-1");
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        long[] color = new long[2 * n];
        int size = 0;

        long max = 0;
        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int idx = str.indexOf(' ');

            int f = Integer.parseInt(str.substring(0, idx));
            if (!map.containsKey(f)) {
                map.put(f, size++);
            }
            int fi = map.get(f);
            color[fi] += Integer.MAX_VALUE;
            max = Math.max(max, (color[fi] / Integer.MAX_VALUE + color[fi] % Integer.MAX_VALUE));

            int b = Integer.parseInt(str.substring(idx + 1));
            if (!map.containsKey(b)) {
                map.put(b, size++);
            }
            if (f != b) {
                int bi = map.get(b);
                color[bi]++;
                max = Math.max(max, (color[bi] / Integer.MAX_VALUE + color[bi] % Integer.MAX_VALUE));
            }
        }
        if (max < (n + 1) / 2) {
            System.out.println("-1");
            return;
        }

        Arrays.sort(color, 0, size);
        for (int i = size - 1; i >= 0; i--) {
            int fn = (int) (color[i] / Integer.MAX_VALUE);
            int bn = (int) (color[i] % Integer.MAX_VALUE);
            if (fn + bn >= (n + 1) / 2) {
                System.out.println(Math.max(0, (n + 1) / 2 - fn));
                return;
            }
        }
        System.out.println("-1");
    }
}


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

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }
    @SuppressWarnings("boxing")
    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(n * 2);
        int[] fn = new int[2 * n];
        int[] bn = new int[2 * n];
        int size = 0;

        for (int i = 0; i < n; i++) {
            String str = in.readLine();
            int f, b;
            int idx = str.indexOf(' ');
            f = Integer.parseInt(str.substring(0, idx));
            b = Integer.parseInt(str.substring(idx + 1));
            {// fi
                if (!map.containsKey(f) && i <= (n + 1) / 2) {
                    map.put(f, size++);
                }
                Integer fi;
                if (null != (fi = map.get(f))) {
                    fn[fi]++;
                }
            }
            {// bi
                if (!map.containsKey(b) && i <= (n + 1) / 2) {
                    map.put(b, size++);
                }
                Integer bi;
                if (f != b && (null != (bi = map.get(b)))) {
                    bn[bi]++;
                }
            }
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < size; i++) {
            if (fn[i] + bn[i] >= (n + 1) / 2) {
                min = Math.min(min, Math.max(0, (n + 1) / 2 - fn[i]));
            }
        }
        if (min == Integer.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
    // class Color {
    // int fn = 0;
    // int bn = 0;
    // }

}


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

/**
 *
 * @author patel
 */
import java.io.*;
import java.util.*;
public class D129 {
    FastScanner in;
    PrintWriter out;
    public class Card{
        int front;
        int rear;
        Card(int f,int r){
            front=f;
            rear=r;
        }
    }
    public void solve() throws IOException {
        in=new FastScanner(System.in);
        int n=in.nextInt();
        Card[] cards = new Card[n];
        /*for(int i=0;i<n;i++){
            cards[i]=new Card(in.nextInt(),in.nextInt());
        }
         *
         */
        int[] ifront=new int[n];
        int[] irear=new int[n];
        Map<Integer,Integer> front=new TreeMap<Integer,Integer>();
        Map<Integer,Integer> rear=new TreeMap<Integer,Integer>();
        for(int i=0;i<n;i++){
            int f=in.nextInt();
            int r=in.nextInt();
            ifront[i]=f;
            irear[i]=r;
            if(front.containsKey(f)){
                int val=front.get(f);
                front.put(f, val+1);
            }else
                front.put(f, 1);
            if(f!=r){
                if(rear.containsKey(r)){
                    int val=rear.get(r);
                    rear.put(r, val+1);
                }else
                    rear.put(r, 1);
            }
        }
        for(int i=0;i<n;i++){
            if(front.containsKey(ifront[i]) && front.get(ifront[i])*2>=n){
                System.out.println(0);
                return;
            }
        }
        int best=987654321;
        for(int i=0;i<n;i++){
            if(front.containsKey(ifront[i]) && rear.containsKey(ifront[i]) && (front.get(ifront[i])+rear.get(ifront[i]))*2>=n){
                best=Math.min(best, rear.get(ifront[i]));
            }
        }
        if(best==987654321)
            System.out.println(-1);
        else
            System.out.println(best);
    }

    public void run() {
        try {
          //  in = new FastScanner(new File(".in"));
         //   out = new PrintWriter(new File(".out"));

            solve();

         //   out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
        FastScanner(InputStream in) {

                br = new BufferedReader(new InputStreamReader(in));

        }
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong(){
            return Long.parseLong(next());
        }
        double nextDouble(){
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] arg) {
        new D129().run();
    }
}


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

/**
 *
 * @author patel
 */
import java.io.*;
import java.util.*;

public class D129 {

    FastScanner in;
    PrintWriter out;

    public class Card {

        int front;
        int rear;

        Card(int f, int r) {
            front = f;
            rear = r;
        }
    }

    public void solve() throws IOException {
        in = new FastScanner(System.in);
        int n = in.nextInt();
        Card[] cards = new Card[n];
        /*for(int i=0;i<n;i++){
        cards[i]=new Card(in.nextInt(),in.nextInt());
        }
         *
         */
        int[] ifront = new int[n];
        int[] irear = new int[n];
        Map<Integer, Integer> map = new TreeMap<Integer, Integer>();
        for (int i = 0; i < n; i++) {
            int f = in.nextInt();
            int r = in.nextInt();
            ifront[i] = f;
            irear[i] = r;
            if (map.containsKey(f)) {
                int val = map.get(f);
                map.put(f, val + 1);
            } else {
                map.put(f, 1);
            }
            if (map.containsKey(r)) {
                int val = map.get(r);
                map.put(r, val + 1);
            } else {
                map.put(r, 1);
            }

        }
        int min = n + 1;
        for (int t : map.keySet()) {
            if (map.get(t) * 2 >= n) {
                int count1 = 0;
                for (int i = 0; i < n; i++) {
                    if (ifront[i] == t) {
                        count1++;
                    }
                }
                int count2 = 0;
                for (int i = 0; i < n; i++) {
                    if (ifront[i] != t && irear[i] == t) {
                        count2++;
                    }
                }

                if ((count1 + count2)>= n-n/2) {
                    min = Math.min(min, n-n / 2 - count1);
                }
            }
        }
        if (min < 0) {
            System.out.println(0);
        } else if (min == n + 1) {
            System.out.println(-1);
        } else {
            System.out.println(min);
        }
    }

    public void run() {
        try {
            //  in = new FastScanner(new File(".in"));
            //   out = new PrintWriter(new File(".out"));

            solve();

            //   out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {

        BufferedReader br;
        StringTokenizer st;

        FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        FastScanner(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));

        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

    public static void main(String[] arg) {
        new D129().run();
    }
}


#include <bits/stdc++.h>
using namespace std;

int T, cnt[26];
string s;

int main() {
    ios::sync_with_stdio(0);
    cin >> T;
    while (T--) {
        cin >> s;
        memset(cnt, 0, sizeof(cnt));
        for (int i = 0; i < s.size(); i++) {
            cnt[s[i] - 'a']++;
        }
        string t;
        vector<pair<int, int> > V;
        for (int i = 0, j; i < 26; i = j + 1) {
            if (!cnt[i]) { j = i; continue; }
            for (j = i + 1; cnt[j]; j++); j--;
            if (j - i > 2 && (j - i + 1) % 2 == 0) {
                for (int k = i + 1; k <= j; k += 2) {
                    t.append(string(cnt[k], k + 'a'));
                }
                for (int k = i; k <= j; k += 2) {
                    t.append(string(cnt[k], k + 'a'));
                }
            } else if (j - i > 3 && (j - i + 1) % 2 == 1) {
                for (int k = i + 1; k < j; k += 2) {
                    t.append(string(cnt[k], k + 'a'));
                }
                for (int k = i; k < j; k += 2) {
                    t.append(string(cnt[k], k + 'a'));
                }
                t.append(string(cnt[j], j + 'a'));
            } else if (i == j) {
                t.append(string(cnt[i], i + 'a'));
            } else { // j <= i + 2
                V.push_back({i, j});
            }
        }
        for (pair<int, int> p : V) {
            int i = p.first, j = p.second;
            if (j == i + 1) {
                t = string(cnt[i], i + 'a') + t;
                t.append(string(cnt[j], j + 'a'));
            } else { // j == i + 2
                t = string(cnt[i], i + 'a') + t;
                t.append(string(cnt[i + 1], i + 1 + 'a'));
                t = string(cnt[j], j + 'a') + t;
            }
        }
        bool flag = 1;
        for (int i = 0; i < t.size() - 1; i++) {
            if (abs(t[i] - t[i + 1]) == 1) flag = 0;
        }
        cout << (flag ? t : "No answer") << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int T, cnt[26];
string s;

int main() {
    ios::sync_with_stdio(0);
    cin >> T;
    while (T--) {
        cin >> s;
        memset(cnt, 0, sizeof(cnt));
        for (int i = 0; i < s.size(); i++) {
            cnt[s[i] - 'a']++;
        }
        string t;
        vector<pair<int, int> > V;
        for (int i = 0, j; i < 26; i = j + 1) {
            if (!cnt[i]) { j = i; continue; }
            for (j = i + 1; cnt[j]; j++); j--;
            if (j - i > 2 && (j - i + 1) % 2 == 0) {
                for (int k = i + 1; k <= j; k += 2) {
                    t.append(string(cnt[k], k + 'a'));
                }
                for (int k = i; k <= j; k += 2) {
                    t.append(string(cnt[k], k + 'a'));
                }
            } else if (j - i > 3 && (j - i + 1) % 2 == 1) {
                for (int k = i + 1; k < j; k += 2) {
                    t.append(string(cnt[k], k + 'a'));
                }
                for (int k = i; k < j; k += 2) {
                    t.append(string(cnt[k], k + 'a'));
                }
                t.append(string(cnt[j], j + 'a'));
            } else if (i == j) {
                t.append(string(cnt[i], i + 'a'));
            } else { // j <= i + 2
                V.push_back({i, j});
            }
        }
        if (!t.size() && V.size() == 1) {
            t = "No answer";
        } else {
            if (!t.size()) t = string(cnt[V[0].first], V[0].first + 'a');
            for (int k = (t.size() ? 0 : 1); k < V.size(); k++) {
                int i = V[k].first, j = V[k].second;
                if (j == i + 1) {
                    t = string(cnt[i], i + 'a') + t;
                    t.append(string(cnt[j], j + 'a'));
                } else { // j == i + 2
                    t = string(cnt[i], i + 'a') + t;
                    t.append(string(cnt[i + 1], i + 1 + 'a'));
                    t = string(cnt[j], j + 'a') + t;
                }
            }
            if (!t.size()) t.append(string(cnt[V[0].second], V[0].second + 'a'));
        }
        cout << t << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int T;
string s;

int main() {
    ios::sync_with_stdio(0);
    cin >> T;
    while (T--) {
        cin >> s;
        sort(s.begin(), s.end());
        string t;
        int l = 0, r = s.size() - 1;
        for (int i = 1; i <= s.size(); i++) {
            if (i & 1) t.push_back(s[l++]);
            else t.push_back(s[r--]);
        }
        if (t.size() > 1) {
            if (abs(t[t.size() - 2] - t.back()) == 1) {
                t = t.back() + t.substr(0, t.size() - 1);
            }
        }
        bool flag = 0;
        for (int i = 0; i < t.size() - 1; i++) {
            if (abs(t[i] - t[i + 1]) == 1) flag = 1;
        }
        if (flag) cout << "No answer" << endl;
        else cout << t << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int T;
string s;

bool chk(string t) {
    bool flag = 1;
    for (int i = 0; i < t.size() - 1; i++) {
        if (abs(t[i] - t[i + 1]) == 1) flag = 0;
    }
    return flag;
}

int main() {
    ios::sync_with_stdio(0);
    cin >> T;
    while (T--) {
        cin >> s;
        sort(s.begin(), s.end());
        string t;
        int l = 0, r = s.size() - 1;
        for (int i = 1; i <= s.size(); i++) {
            if (i & 1) t.push_back(s[l++]);
            else t.push_back(s[r--]);
        }
        if (t.size() > 1 && !chk(t)) {
            string old = t;
            while (!chk(t)) {
                t = t.back() + t.substr(0, t.size() - 1);
                if (t == old) break;
            }
            if (!chk(t)) {
                t.clear();
                int l = 0, r = s.size() - 1;
                for (int i = 0; i < s.size(); i++) {
                    if (i & 1) t.push_back(s[l++]);
                    else t.push_back(s[r--]);
                }
                if (t.size() > 1 && !chk(t)) {
                    string old = t;
                    if (abs(t[t.size() - 2] - t.back()) == 1) {
                        while (!chk(t)) {
                            t = t.back() + t.substr(0, t.size() - 1);
                            if (t == old) break;
                        }
                    }
                }
            }
        }
        if (!chk(t)) cout << "No answer" << endl;
        else cout << t << endl;
    }
    return 0;
}
// abcde


#include<bits/stdc++.h>
#define N 1000010
#define INF 0x3f3f3f3f
#define eps 1e-10
// #define pi 3.141592653589793
// #define P 1000000007
#define LL long long
#define pb push_back
#define fi first
#define se second
#define cl clear
#define si size
#define lb lower_bound
#define ub upper_bound
#define mem(x) memset(x,0,sizeof x)
#define sc(x) scanf("%d",&x)
#define scc(x,y) scanf("%d%d",&x,&y)
#define sccc(x,y,z) scanf("%d%d%d",&x,&y,&z)
using namespace std;
typedef pair<int,int> pp;

char x[105];

int main(){
	int T;
	sc(T);
	while(T--){
		scanf("%s",x);
		int n=strlen(x);
		int ffg=0;
		for (int i=0;i<10000;i++){
			random_shuffle(x,x+n);
			int fg=0;
			for(int i=1;i<n;i++)if (abs(x[i]-x[i-1])==1){
                fg=1; break;
            }
            if (!fg) {ffg=1;break;}
		}
		if(ffg) printf("%s\n",x);else puts("No answer");
	}{}

}


#include<bits/stdc++.h>
#define N 1000010
#define INF 0x3f3f3f3f
#define eps 1e-10
// #define pi 3.141592653589793
// #define P 1000000007
#define LL long long
#define pb push_back
#define fi first
#define se second
#define cl clear
#define si size
#define lb lower_bound
#define ub upper_bound
#define mem(x) memset(x,0,sizeof x)
#define sc(x) scanf("%d",&x)
#define scc(x,y) scanf("%d%d",&x,&y)
#define sccc(x,y,z) scanf("%d%d%d",&x,&y,&z)
using namespace std;
typedef pair<int,int> pp;

char x[105];

int main(){
    int T;
    sc(T);
    while(T--){
        scanf("%s",x);
        int n=strlen(x);
        int d[30]={0};
        for (int i=0;i<n;i++) d[x[i]-'a']++;
        int v[30];int cnt=0;
        for (int i=0;i<26;i++) if (d[i])v[++cnt]=i;
        int ffg=0;
        for (int i=0;i<100000;i++){
            random_shuffle(v+1,v+cnt+1);
            int fg=0;
            for (int j=2;j<=cnt;j++)
                if (abs(v[j]-v[j-1])==1) {fg=1;break;}
            if (!fg) {ffg=1;break;}
        }
        if (!ffg)puts("No answer");else
        {
            for(int i=1;i<=cnt;i++)
            while(d[v[i]]){
                cout<<(char)('a'+v[i]);
                d[v[i]]--;
            }
            cout<<endl;
        }
    }

}


#include<bits/stdc++.h>
#define N 1000010
#define INF 0x3f3f3f3f
#define eps 1e-10
// #define pi 3.141592653589793
// #define P 1000000007
#define LL long long
#define pb push_back
#define fi first
#define se second
#define cl clear
#define si size
#define lb lower_bound
#define ub upper_bound
#define mem(x) memset(x,0,sizeof x)
#define sc(x) scanf("%d",&x)
#define scc(x,y) scanf("%d%d",&x,&y)
#define sccc(x,y,z) scanf("%d%d%d",&x,&y,&z)
using namespace std;
typedef pair<int,int> pp;

char x[105];

int main(){
	int T;
	sc(T);
	while(T--){
		scanf("%s",x);
		int n=strlen(x);
		int d[30]={0};
		for (int i=0;i<n;i++) d[x[i]-'a']++;
		int v[30];int cnt=0;
		for (int i=0;i<26;i++) if (d[i])v[++cnt]=i;
		for (int i=4;i<=cnt;i+=4) swap(v[i-3],v[i-1]),swap(v[i-2],v[i-1]),
			swap(v[i-1],v[i]);
		int b=1;
		if (cnt%4==2){
			v[0]=v[cnt];
			b--;cnt--;
		}else
		if (cnt%4==3){
			v[0]=v[cnt-1]; v[cnt-1]=v[cnt];
			b--;cnt--;
		}
		char ans[110]; int k=0;
		for(int i=b;i<=cnt;i++)
			while(d[v[i]]){
				ans[++k]=(char)('a'+v[i]);
				d[v[i]]--;
			}
		ans[k+1]=0;int fg=0;
		for (int i=2;i<=k;i++) if (abs(ans[i]-ans[i-1])==1) fg=1;
		if (!fg)cout<<ans+1<<endl;else puts("No answer");
	}

}


#include<bits/stdc++.h>
#define N 1000010
#define INF 0x3f3f3f3f
#define eps 1e-10
// #define pi 3.141592653589793
// #define P 1000000007
#define LL long long
#define pb push_back
#define fi first
#define se second
#define cl clear
#define si size
#define lb lower_bound
#define ub upper_bound
#define mem(x) memset(x,0,sizeof x)
#define sc(x) scanf("%d",&x)
#define scc(x,y) scanf("%d%d",&x,&y)
#define sccc(x,y,z) scanf("%d%d%d",&x,&y,&z)
using namespace std;
typedef pair<int,int> pp;

char x[105];

int main(){
	int T;
	sc(T);
	while(T--){
		scanf("%s",x);
		int n=strlen(x);
		int d[30]={0};
		for (int i=0;i<n;i++) d[x[i]-'a']++;
		int v[30];int cnt=0;
		for (int i=0;i<26;i++) if (d[i])v[++cnt]=i;
		for (int i=4;i<=cnt;i+=4) swap(v[i-3],v[i-1]),swap(v[i-2],v[i-1]),
			swap(v[i-1],v[i]);
		int b=1;
		if (cnt%4==2){
			v[0]=v[cnt];
			b--;cnt--;
		}else
		if (cnt%4==3){
			v[0]=v[cnt-1]; v[cnt-1]=v[cnt];
			b--;cnt--;
		}
		char ans[110]; int k=0;
		for(int i=b;i<=cnt;i++)
			while(d[v[i]]){
				ans[++k]=(char)('a'+v[i]);
				d[v[i]]--;
			}
		ans[k+1]=0;int fg=0;
		for (int i=2;i<=k;i++) if (abs(ans[i]-ans[i-1])==1) fg=1;
		if (!fg)cout<<ans+1<<endl;else puts("No answer");
	}{}{}

}


#include<bits/stdc++.h>
#define N 1000010
#define INF 0x3f3f3f3f
#define eps 1e-10
// #define pi 3.141592653589793
// #define P 1000000007
#define LL long long
#define pb push_back
#define fi first
#define se second
#define cl clear
#define si size
#define lb lower_bound
#define ub upper_bound
#define mem(x) memset(x,0,sizeof x)
#define sc(x) scanf("%d",&x)
#define scc(x,y) scanf("%d%d",&x,&y)
#define sccc(x,y,z) scanf("%d%d%d",&x,&y,&z)
using namespace std;
typedef pair<int,int> pp;

char x[105];

int main(){
	int T;
	sc(T);
	while(T--){
		scanf("%s",x);
		int n=strlen(x);
		int ffg=0;
		for (int i=0;i<10000;i++){
			random_shuffle(x,x+n);
			int fg=0;
			for(int i=1;i<n;i++)if (abs(x[i]-x[i-1])==1){
                fg=1; break;
            }
            if (!fg) {ffg=1;break;}
		}
		if(ffg) printf("%s\n",x);else puts("No answer");
	}

}


#include<bits/stdc++.h>
#define N 1000010
#define INF 0x3f3f3f3f
#define eps 1e-10
// #define pi 3.141592653589793
// #define P 1000000007
#define LL long long
#define pb push_back
#define fi first
#define se second
#define cl clear
#define si size
#define lb lower_bound
#define ub upper_bound
#define mem(x) memset(x,0,sizeof x)
#define sc(x) scanf("%d",&x)
#define scc(x,y) scanf("%d%d",&x,&y)
#define sccc(x,y,z) scanf("%d%d%d",&x,&y,&z)
using namespace std;
typedef pair<int,int> pp;

char x[105];

int main(){
	int T;
	sc(T);
	while(T--){
		scanf("%s",x);
		int n=strlen(x);
		int d[30]={0};
		for (int i=0;i<n;i++) d[x[i]-'a']++;
		int v[30];int cnt=0;
		for (int i=0;i<26;i++) if (d[i])v[++cnt]=i;
		for (int i=4;i<=cnt;i+=4) swap(v[i-3],v[i-1]),swap(v[i-2],v[i-1]),
			swap(v[i-1],v[i]);
		int b=1;
		if (cnt%4==2){
			v[0]=v[cnt];
			b--;cnt--;
		}else
		if (cnt%4==3){
			if (v[cnt-1]!=v[cnt]-1) swap(v[cnt-1],v[cnt]);else{
				v[0]=v[cnt-1]; v[cnt-1]=v[cnt];
			b--;cnt--;
			}

		}
		char ans[110]; int k=0;
		for(int i=b;i<=cnt;i++)
			while(d[v[i]]){
				ans[++k]=(char)('a'+v[i]);
				d[v[i]]--;
			}
		ans[k+1]=0;int fg=0;
		for (int i=2;i<=k;i++) if (abs(ans[i]-ans[i-1])==1) fg=1;
		if (!fg)cout<<ans+1<<endl;else puts("No answer");
	}

}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (1ll*a*b)/gcd(a, b);}
bool isGood(string &s)
{
    for(int i=0;i<s.size()-1;++i)
    {
        if(abs(s[i]-s[i+1])==1) return false;
    }
    return true;
}
void solve(string &s)
{
    sort(s.begin(),s.end());
    map<char,int> freq; for(auto l : s) freq[l]++;
    s.resize(unique(s.begin(),s.end())-s.begin());int c = 0;
    while(!isGood(s))
    {
        random_shuffle(s.begin(),s.end());
        c++;
        if(c==10000) {cout<<"No answer"; return;}
    }
    for(auto l : s)
    {
        while(freq[l]--) cout<<l;
    }
    cout<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        string s; cin>>s;
        solve(s);
    }
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (1ll*a*b)/gcd(a, b);}
bool isGood(string &s)
{
    for(int i=0;i<s.size()-1;++i)
    {
        if(abs(s[i]-s[i+1])==1) return false;
    }
    return true;
}
void solve(string &s)
{
    sort(s.begin(),s.end());
    map<char,int> freq; for(auto l : s) freq[l]++;
    s.resize(unique(s.begin(),s.end())-s.begin());int c = 0;
    while(!isGood(s))
    {
        random_shuffle(s.begin(),s.end());
        c++;
        if(c==1000) {cout<<"No answer"; return;}
    }
    for(auto l : s)
    {
        while(freq[l]--) cout<<l;
    }
    cout<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        string s; cin>>s;
        solve(s);
    }
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (1ll*a*b)/gcd(a, b);}
bool isGood(string s)
{
    for(int i=0;i<s.size()-1;++i)
    {
        if(abs(s[i]-s[i+1])==1) return false;
    }
    return true;
}
void solve(string s)
{
    sort(s.begin(),s.end());
    unordered_map<char,int> freq; for(auto l : s) freq[l]++;
    s.resize(unique(s.begin(),s.end())-s.begin());int c = 0;
    while(!isGood(s))
    {
        random_shuffle(s.begin(),s.end());
        c++;
        if(c==10000) {cout<<"No answer\n"; return;}
    }
    for(auto l : s)
    {
        while(freq[l]--) cout<<l;
    }
    cout<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        string s; cin>>s;
        solve(s);
    }
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (1ll*a*b)/gcd(a, b);}
bool isGood(string s)
{
    for(int i=0;i<s.size()-1;++i)
    {
        if(abs(s[i]-s[i+1])==1) return false;
    }
    return true;
}
void solve(string s)
{
    sort(s.begin(),s.end());
    unordered_map<char,int> freq; for(auto l : s) freq[l]++;
    s.resize(unique(s.begin(),s.end())-s.begin());int c = 0;
    while(!isGood(s))
    {
        random_shuffle(s.begin(),s.end());
        c++;
        if(c==10000) {cout<<"No answer"; return;}
    }
    for(auto l : s)
    {
        while(freq[l]--) cout<<l;
    }
    cout<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        string s; cin>>s;
        solve(s);
    }
}