Approach hintTry it first, then revealHide
Run a DFS from the root carrying the length of the current run of consecutive cat vertices; prune a branch once the run exceeds m, and count the leaves you reach.
Run a DFS from the root carrying the length of the current run of consecutive cat vertices; prune a branch once the run exceeds m, and count the leaves you reach.