Adding the 1st version of the solution of spoj classical problem PALIN