I am not able to fix counter for ( ans ) atring

My Code https://ide.codingblocks.com/s/155240
Hackerblock link https://hack.codingblocks.com/app/contests/987/p/356

Hi @harshkumar.877587
increment the count when str.length() ==0