java very easy solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public boolean check(int fre[],int arr[])\n    {\n        for(int i=0;i<26;i++)\n        {\n            if(arr[i]<fre[i])\n            {\n                return false; \n            }\n        }\n        return true;\n    }\n    public long validSubstringCount(String word1, String word2) {\n        int n=word1.length();\n        int fre[]=new int[26];\n        for(int i=0;i<word2.length();i++)\n        {\n            char ch=word2.charAt(i);\n            fre[ch-\'a\']++;\n        }\n        int arr[]=new int[26];\n        int i=0;\n        int j=0;\n        long ans=0;\n        while(i<n)\n        {\n            char ch=word1.charAt(i);\n            arr[ch-\'a\']++;\n            while(j<=i&&check(fre,arr))\n            {\n                ans+=(n-i);\n                arr[word1.charAt(j)-\'a\']--;\n                j++;\n            }\n            i++;\n        }\n        return ans;  \n    }\n}\n```
['Java']