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

int main() 
{
    // index    1   2    3   4   5  6   7   8   9
    int b[9] = {5 , 5 , 5 , 3 , 3 , 2 , 2 , 1 , 1};
    int n = 9;

    b[n+1] = 0; // 1 - based indexing
    /*
    Element , frequency 
           5             3
           3             2
           2             2
           1             2
    */
    unordered_map<int,int>k;
    for(int i=1; i<=n; i++)
    {
        k[b[i]] = k[b[i]] + 1;
    }

    /* 
      <(5,3)<5 , 3>>g; // g(5,3)
      <(3,2)<3 , 2>g; // g(3,2)
      <(2,2)<2 , 2>g; // g(2,2)
      <(1,2)<1 , 2>g; // g(1.2)
      
    */
    vector<pair<int,int>>g;
    for(auto  u=k.begin();  u!=k.end();  u++) // u is an iterator
    {

        //                     Element  Frequency
        g.push_back({u->first, u->second}); // to access 'u' . dot operator we not arrow -> symbol we use to acess it 
    }

    int size = g.size(); // map size
    int step = 0;

    for(int i=size - 1;  i>=1;  i--)
    {
        g[i-1].second = g[i-1].second + g[i].second;
        step = step + g[i].second;
        g[i].second = 0;
    }
    cout<<step<<endl;

    return 0;
}