/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		int arr[] = {1,1,3,4,1,4,4,4,4};
		int n = arr.length;
		int maxFreq=0;
		
		Map<Integer,Integer> map = new HashMap<>();
		for(int i = 0;i<n;i++){
			map.put(arr[i],map.getOrDefault(arr[i],0)+1);
		}
		
		for(Map.Entry<Integer,Integer> entry : map.entrySet()){
			int Freq = entry.getValue();
			if(Freq>maxFreq){
				maxFreq = Freq;
			}
		}
		System.out.println(n-maxFreq);
	}
}