Why do I get NZEC error in KNIGHTMV

I am not able to figure out why am i getting a NZEC error. If possible please help me in this case.Here is my code to the question KNIGHTMV
http://www.codechef.com/viewsolution/7034072

The problem is when the length of input string is less than 5, and if input is “s” you are accessing char at 2 then it is Runtime Error resulting in NZEC. Now it’s your turn to code it up!