solved problem 14 in php