stacking pancakes

Anyone please help how to form dp formula for the following problem…