I trying to count the pair of brackets given and I wrote the below code but it doesn\'t seem to be counting the pairs correctly. The first pair is correct but the rest is 1