The retained earnings in the second year will be equal to the retained earnings in the first year, plus the profit for the year, less any dividends for the year.
So if you have the SOFP’s (we stopped calling it the balance sheet many years ago!) then you know the retained earnings figure. If you know what the dividends paid were, then you can calculate what the profit must have been.