The work-energy theorem says that the total work done on the block is equal to the difference of its kinetic energies at points B and A. Then the total work done on the block is
Friction acts on the block to oppose its motion, so it does negative work on the block, -4.5 J.
The only other force acting on the block as it moves is the force P. Let
be the work done by the force P. Then the total work done on the block is