a variation of 1437D
How to solve 1437D - Дерево минимальной высоты if the question asked to count the number of valid trees?