Instead of getting yes or no, how to get the count of stack

Can you change that in this code

hello @kishoretaru
pls check ur previous thread , i have shared the code implementation of the same