I have a simple foreach loop that outputs an ordered list from a CPT 'post_subscribers' and an associated meta key called 'project'.

    $theposts = get_posts( array(
        'post_type'   => 'post_subscriber',
        'post_status' => 'publish',
        'numberposts' => -1,
    ) ); 
    

    echo '<ol>';
        foreach( $theposts as $p ): 

            $project_name = get_post_meta($p->ID, 'project', true);

            echo '<li class="mb-3">';

                echo get_the_title($project_name);
            
            echo '</li>';
        
        endforeach;

    echo '</ol>'; 

    echo 'Total projects - '. count($theposts)."</br>";


My list will generate:

1. Project title one
2. Project title two
3. Project title two
4. Project title two
5. Project title three
6. Project title one

Total projects - 6

Q) Within my generated ordered list there are several exact matching '$project_name'(s). How can I count the matching '$project_name'(s) and display the count for them as a separate result?

EG result: There are 3 projects with the name 'Project title two'.

It seems like a relatively simple task but I can't get my head around it? Many thanks in advance :-)