calculate minimum pay of the problem buy books with discouts