Solving the problem with input