SPOJ.com - Problem ABA12C

SPOJ.com - Problem ABA12C Cannot think of solution please help in approach