Paco had w cookies. He gave x cookies to his friend and ate y cookies. How many more cookies did he eat than those he gave to his friend?
Paco had w cookies. He gave x cookies to his friend. 

That means that he has w-x cookies left. 

He ate y cookies. 

That means that he has w-x-y cookies left. 

We want to know how many more cookies he ate than those he gave to his friend. 

That means we want to know how many cookies he gave to his friend minus how many cookies he ate. 

That's x-(w-x-y), or y-x.