First we have to rename the bound $y$ to $z$ to avoid capture: $$(\lambda x.(\lambda z. (x(\lambda x.xz))))y$$ Then we may substitute $y$ for any bound occurence of $x$: $$(\lambda z. (y(\lambda x.xz)))$$
First we have to rename the bound $y$ to $z$ to avoid capture: $$(\lambda x.(\lambda z. (x(\lambda x.xz))))y$$ Then we may substitute $y$ for any bound occurence of $x$: $$(\lambda z. (y(\lambda x.xz)))$$