why i am getting wrong answer ?

Problem : ACUPALIN Problem - CodeChef

My Solution : CodeChef: Practical coding for everyone