Restrict user to insert more than 18 task in bpmn diagram

My requirement is when a user tries to insert task element more than certain number say 18, bpmn diagram must not allow the element to insert into the diagram. Is there a way to achieve it ?

Many thanks.

Hi,

What did you tried to do and what were you struggling with?

Please consider looking into examples (like this) as a starting point.

Thanks,
Vladimir