On the number of principal components in high dimensions