whats wrong with my code..its is showing wrong answer??

https://www.codechef.com/viewsolution/19962442

As an example of input that gives a wrong answer:

CHHCHEFEF

should give answer of 2; your code reports 1.

Thnanks…i was unable to find out.

This means I need to change the whole logic???right?

Yes, probably you do need to change your method.