Sliding window. Simple and clear solution
\nclass Solution:\n    def validSubstringCount(self, word1: str, word2: str) -> int:\n        cnt = Counter(word2)\n        ans, left, diff = 0, 0, len(cnt)\n  
```\nclass Solution:\n    def validSubstringCount(self, word1: str, word2: str) -> int:\n        cnt = Counter(word2)\n        ans, left, diff = 0, 0, len(cnt)\n        for ch in word1:\n            cnt[ch] -= 1\n            if cnt[ch] == 0:\n                diff -= 1\n            while diff == 0:\n                cnt[word1[left]] += 1\n                if cnt[word1[left]] == 1:\n                    diff += 1\n                left += 1\n            ans += left\n        return ans\n```
['Sliding Window', 'Python3']