Need help with WITTYBOY

Can someone tell me the approach to this question?
SPOJ.com - Problem WITTYBOY