Fixed the formula to compute the number of registers necessary.