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

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

import java.time.* ;
import java.util.stream.* ;

/* 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
	{

List< String > inputs = List.of( "2021-07-01", "2021-08-20", "2021-08-25", "2021-09-05", "2022-01-06", "2022-06-07" );

Map< YearMonth , Integer > monthCounts = 
    inputs
        .stream()
        .map( input -> LocalDate.parse( input ) )
        .collect(
            Collectors.groupingBy( date -> 
                           YearMonth.from( date ) ,
                           Collectors.summingInt( date -> 1 )
            )
        )
;

System.out.println( monthCounts ) ;

	}
}