Count merged cells in calc

I am using a simple time tracker for tasks in calc (libreoffice The task names are entered from a list, and the cells are merged for continuous durations.
In order to calculate the total time per task, I need to know a count of rows spanned by each task. A simple COUNTIF() would only return the number of occurrences of the task string, whereas I am looking for a metric that counts the number of cells in the merged ones.

I searched a lot, but cannot figure out how to implement this. I know it is not advised to use merged cells for calculations etc. but having to enter text for every entry makes it more tedious.

Thank you for any input!

Got some interesting responses here :

And a solution that fits my requirement.