Optimal allocation of storage space