public static Map<String, String> createMap() {
        Map <String, String> mapDictionary = new HashMap<>();
        mapDictionary.put("Иванов", "Иван");
        mapDictionary.put("Шевчук", "Иван");
        mapDictionary.put("Колосихин", "Петр");
        mapDictionary.put("Андросенко", "Александр");
        mapDictionary.put("Верзунов", "Вячеслав");
        mapDictionary.put("Жиров", "Иван");
        mapDictionary.put("Иванова", "Валя");
        mapDictionary.put("Иванов", "Иван");
        mapDictionary.put("Потапов", "Михаил");
        mapDictionary.put("Чернышевский", "Олег");
        return mapDictionary;
    }
public static void main(String[] args) {
        /*
Map <String, String> map = createMap();
        System.out.println(getCountTheSameFirstName(map, "Иван"));
        System.out.println(getCountTheSameLastName(map, "Иванов"));
        */
    }
в консоль выводится:
3
1

Process finished with exit code 0
У меня 2 фамилии "Иванов" и 4 имени "Иван"