The subnet prefix length is calculated based on the number of hosts required. The formula used is:
Prefix Length = 32 - log2(Number of Hosts + 2)