Some cases are not satisfying

I checked the condition for p>c<n if its true then count is initialized again.