The amount of substance affects the total energy through the concept of molar heat capacity. Molar heat capacity is defined as the amount of heat required to raise the temperature of one mole of a substance by one degree Celsius. Therefore, the more substance there is, the more heat energy is required to raise its temperature.
For example, if we have one mole of a substance, it will require a certain amount of energy to raise its temperature by one degree Celsius. However, if we have two moles of the same substance, it will require twice as much energy to raise the temperature of the larger amount by the same one degree Celsius.
Additionally, the amount of substance can affect the total energy through the concept of specific heat capacity. Specific heat capacity is defined as the amount of heat required to raise the temperature of one unit of mass (usually one gram) of a substance by one degree Celsius. Therefore, if we have more mass of a substance, it will require more energy to raise the temperature of the larger amount by the same one degree Celsius.
In summary, the amount of substance affects the total energy through the concepts of molar heat capacity and specific heat capacity, which determine how much energy is required to raise the temperature of a given amount of substance.