Could do with a little help sorting out how these algebraic manipulations come about. I'm studying economics but my algebra is not good enough to work this out.

There are subscripts which represent different time periods which will appear as full size digits as I don't know how to use the proper notation for this site:

1. (D0(1+r) - FS/Y0(1+g)) - D0/Y0

2. = (D0(r-g)/Y0(1+g)) - FS/(Y0(1+g))

Any pointers about how the transformation of 1. into 2. is done much appreciated.