A stratification on the moduli of K3 surfaces