help in DIRECTI

Getting wrong answer For DIRECTI with below code

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