Adding count substrings problem