Easy Python Solution
Code\npython3 []\nfrom collections import Counter, defaultdict\n\nclass Solution:\n    def validSubstringCount(self, word1: str, word2: str) -> int:\n        wo
# Code\n```python3 []\nfrom collections import Counter, defaultdict\n\nclass Solution:\n    def validSubstringCount(self, word1: str, word2: str) -> int:\n        word1_count, word2_count = defaultdict(int), Counter(word2)\n\n        answer = 0\n\n        left = right = 0\n\n        while right < len(word1):\n            while right < len(word1) and any(word1_count[i] < word2_count[i] for i in word2_count):\n                word1_count[word1[right]] += 1\n                right += 1\n            \n            while left < right and all(word1_count[i] >= word2_count[i] for i in word2_count):\n                answer += len(word1) + 1 - right\n                word1_count[word1[left]] -= 1\n                left += 1\n        \n        return answer\n\n```
['Python3']