Hi @SanjayGupta,
It comes to my mind that via xtk: workflow you could do it. Using XML , you could count the number of activities to determine how many does a workflow has.
To build it correctly you will need to use a JavaScript activity and an alert activity to see how the JS activity behaves.
You can read the following documentation:
workflow
About workflow activities | Adobe Campaign
Build a workflow | Adobe Campaign
If you need more assistance on building de JS code, just let me know.
Best regards,
Celia