How to Calculate Retained Earnings: Formula & Example