Derivative of a set of equations

I am a new learner of Mathematica, I think this question should be simple, but I just can’t get the correct answer…

This is my equations:

p=x+y
q=2x+y
r=p+q

And I want to get the derivation of r by x, so the answer should be 3 (r=(x+y)+(2x+y)=3x+y)

But the output I got is a+b ??!! Why?

enter image description here