getK function

Estimate the number of common factors K