Re-arranging formula question

Hi All,

I'm having a slight problem with a re-arranging formula question (not a marked one, the answers are on the sheet, I just don't know how to get to the specified answer) it should be easy and I'm pretty embarrassed that I can't do it.

The question is make 'x' the subject of:

$\displaystyle r^2 = (x - a)^2 + y^2$

According to the sheet the correct answer is

$\displaystyle x = sqrt(r^2 - y^2) + a$

I've tried it various ways though and usually end up with

$\displaystyle x = r - y + a$

If anyone could break down how you get the correct answer that would be great. Thanks in advance.