At point S, the total energy is equal to the total energy of the system because kinetic energy has been transformed to potential energy.
In a closed system (ignoring air resistance and other losses), the total mechanical energy (kinetic + potential) is conserved. As the baseball is thrown upwards, its kinetic energy decreases while its potential energy increases, but the total remains constant.