How to solve "Do you want to build a snowman" ?

https://www.codechef.com/KOL18ROL/problems/SNOWMAN , we found the draw case which is 1. And L case which is a Fibonacci like sequence. But that we found by generating the Grundy numbers XD. So don’t really know how to print the number of snow balls to pick for winning case. Can someone tell the AC logic ?

Fibonacci Nim

//