Solve question #3 (substring check) on spoj in the hard way.