added solution to the count substrings problem