added second part of the formula of the problem.