solve the valid number problem.