Determining the number of optimal clusters