Section 731, subdivision (b) only applies to commitments to CYA. The minor appealed from an order committing her to a camp program for the maximum term of confinement. She contended that the juvenile court failed to exercise its discretion to set the term based on the facts of the case, and that Welfare and Institutions Code section 731, subdivision (b) gives the juvenile court discretion to impose less than the maximum term. The appellate court rejected the argument and affirmed. Section 731(b) exclusive reference to CYA demonstrates that the Legislature intended it to apply only to CYA commitments.