Degree Of Freedom Formula In Thermodynamics