Wrong Answer for MAXCOUNT

I’m getting Wrong Answer for my code although it worked fine for a number of test cases that I checked.
Please tell me where I’m going wrong.
http://www.codechef.com/viewsolution/4663881