Added the function for the problem.