Count Number of Homogenous Substrings