The important thing to note in this problem is that there is a sequence of transactions that are occurring, so that when a fraction is given for the amount remaining, the fact that they ask it after a proceeding transaction is completed is important. Here what I mean. Here are the transactions in the problem:
(1) John starts with P pencils;
(2) John gives 2/3 of his pencils to Roy;
(3) John gives 1/4 of his remaining pencils to Maria.
(4) John now has ? pencils remaining.
So in (1) he has P; then he has gives 2/3 of that away, which means he has (1/3) P remaining after (2). He then gives 1/4 of that amount away, meaning that he has 3/4 of the amount he had after step (2) at the end of step (3). That is, he has (3/4)*(1/3)P = (1/4)P. Thus in step (4) he has (1/4)P.
To check, say John has 12 pencils. Then:
(1) John starts with 12 pencils;
(2) John gives 2/3 of his pencils to Roy, that is 8 pencils to Roy. John now has 4 pencils left.
(3) John gives 1/4 of his remaining pencils to Maria, or 1 pencil to Maria. He therefore has 3 pencils left.
(4) John now has 3 pencils remaining, which is 1/4 the original amount of 12 pencils. And our answer is confirmed for the case of P = 12 pencils.
As always, if you need more help, please clarify where you are in the process and what's giving you trouble. I'd be more than happy to continue to assist.
If we've been helpful in answering your question, please consider being one of the first to stop by our brand new Facebook page at www.facebook.com/protutorcompany.