Need help with WITTYBOY

Can someone tell me the approach to this question?
https://www.spoj.com/problems/WITTYBOY/