//q1
// pactice
 
#pragma warning(disable:4996)
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wwrite-strings"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#define MAX_NUMBER 100000
#define MAX_STRING 700000

	int aOdd[MAX_NUMBER/2];
	int aEven[MAX_NUMBER/2];
	int aOddPattern[MAX_NUMBER];
	int aEvenPattern[MAX_NUMBER];
	char sInput[MAX_STRING+1]="";

int main() {
 
	char* psInput=NULL;
	int nNumberOfNumber=0;
 
	int i=0;
	int iTemp=0;
	int iOddTopNumber=0;
	int iOddTopCount=0;
	int iOddTopNumber_Temp=0;
	int iOddTopCount_Temp=0;
	int iOdd2ndNumber=0;
	int iOdd2ndCount=0;

	int iEvenTopNumber=0;
	int iEvenTopCount=0;
	int iEvenTopNumber_Temp=0;
	int iEvenTopCount_Temp=0;
	int iEven2ndNumber=0;
	int iEven2ndCount=0;

	int iHaveSameNumber=0;

	int iTest1=0;
	int iTest2=0;

	for(i=0;i;i++){
		aOdd[i]=0;
		aEven[i]=0;
		aOddPattern[i]=0;
		aEvenPattern[i]=0;
	}
	// read line 1
	gets(sInput);
	nNumberOfNumber=atoi(sInput);

	// read line 2
	gets(sInput);
	psInput = strtok(sInput," ");
	for (i=0;i<nNumberOfNumber;i++){
		iTemp=atoi(psInput);
		if(i%2){
			//Odd
			aOdd[i/2]=iTemp;

			aOddPattern[iTemp-1]=aOddPattern[iTemp-1]+1;

			if(aOddPattern[iTemp-1]>iOddTopCount){
				iOddTopNumber=iTemp;
				iOddTopCount=aOddPattern[iTemp-1];
			}

		} else {
			// Even
			aEven[i/2]=iTemp;

			aEvenPattern[iTemp-1]=aEvenPattern[iTemp-1]+1;
			if(aEvenPattern[iTemp-1]>iEvenTopCount){
				iEvenTopNumber=iTemp;
				iEvenTopCount=aEvenPattern[iTemp-1];
			}
		}
		psInput = strtok(NULL," ");
	}
	if(iOddTopNumber==iEvenTopNumber){
		iHaveSameNumber=1;
		for(i=0;i<nNumberOfNumber;i++){
			if(iOddTopNumber!=i+1 && iOddTopCount == aOddPattern[i]){
				iOddTopNumber=i+1;
				iHaveSameNumber=0;
			}
		}
		if(iHaveSameNumber){
			for(i=0;i<nNumberOfNumber;i++){
				if(iEvenTopNumber!=i+1 && iEvenTopCount == aEvenPattern[i]){
					iEvenTopNumber=i+1;
					iHaveSameNumber=0;
				}
			}
		}
	}

	if(!iHaveSameNumber){
		printf("%d\n",(nNumberOfNumber-iOddTopCount-iEvenTopCount));
	} else {
		
			for(i=0;i<nNumberOfNumber;i++){
				if(iOddTopNumber!=i+1 && iOdd2ndCount < aOddPattern[i]){
					iOdd2ndNumber=i+1;
					iOdd2ndCount=aOddPattern[i];
				}
				if(iEvenTopNumber!=i+1 && iEven2ndCount < aEvenPattern[i]){
					iEven2ndNumber=i+1;
					iEven2ndCount=aEvenPattern[i];
				}
			}

			iTest1=iOddTopCount+iEven2ndCount;
			iTest2=iEvenTopCount+iOdd2ndCount;

			if(!iOdd2ndNumber){
				iTest1=nNumberOfNumber-iOddTopCount-iEven2ndCount;
				iTest2=nNumberOfNumber-iEvenTopCount;
			} else if (!iEven2ndNumber){
				iTest1=nNumberOfNumber-iOddTopCount;
				iTest2=nNumberOfNumber-iEvenTopCount-iOdd2ndCount;
			} else {
				iTest1=nNumberOfNumber-iOddTopCount-iEven2ndCount;
				iTest2=nNumberOfNumber-iEvenTopCount-iOdd2ndCount;
			}

			if(iTest1<iTest2){
				printf("%d\n",iTest1);
			} else {
				printf("%d\n",iTest2);
			}
	}
/*
		if(iOddTopCount>iEvenTopCount){
			iEvenTopNumber_Temp=iEvenTopNumber;
			iEvenTopNumber=0;
			iEvenTopCount_Temp=iEvenTopCount;
			iEvenTopCount=0;
			for(i=0;i<nNumberOfNumber;i++){
				if(iOddTopNumber!=i+1 && iEvenTopCount < aEvenPattern[i]){
					iEvenTopNumber=i+1;
					iEvenTopCount=aEvenPattern[i];
				}
			}
			if(!iEvenTopNumber){
				iEvenTopNumber=iEvenTopNumber_Temp;
				iEvenTopCount=iEvenTopCount_Temp;
				printf("%d\n",(nNumberOfNumber-iOddTopCount));
			}else {
				printf("%d\n",(nNumberOfNumber-iOddTopCount-iEvenTopCount));
			}
		} else {
			iOddTopNumber_Temp=iOddTopNumber;
			iOddTopNumber=0;
			iOddTopCount_Temp=iOddTopCount;
			iOddTopCount=0;
			for(i=0;i<nNumberOfNumber;i++){
				if(iEvenTopNumber!=i+1 && iOddTopCount < aOddPattern[i]){
					iOddTopNumber=i+1;
					iOddTopCount=aOddPattern[i];
				}
			}
			if(!iOddTopNumber){
				iOddTopNumber=iOddTopNumber_Temp;
				iOddTopCount=iOddTopCount_Temp;
				printf("%d\n",(nNumberOfNumber-iEvenTopCount));
			}else {
				printf("%d\n",(nNumberOfNumber-iOddTopCount-iEvenTopCount));
			}
		}
	}
*/ 

	return 0;
}


Measured memory_bytes: 1920