Java 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```\nclass Solution {\n    long mod = 1000000000 + 7;\n    public long factorial(int a){\n        long num = 1;\n        while(a>0){\n            num = mul(num, a);\n            --a;\n        }\n        return num;\n    }\n    public long[] extendedEuclid(long a, long b){\n        if(b == 0)\n            return new long[]{1,0};\n        long[] arr = extendedEuclid(b, a%b);\n        long x = arr[1];\n        long y = arr[0]  -(a/b)*arr[1];\n        return new long[]{x,y};\n    }\n    public long mul(long a, long b){\n        if(b == 0)\n            return 0;\n\n        long halfAns = mul(a, b/2);\n\n        if(b%2 == 0)\n            return (halfAns + halfAns)%mod;\n        \n        return (halfAns + halfAns + a)%mod;\n    }\n    public int countPermutation(String newString){\n        int[] freq = new int[26];\n        for(int i=0;i<newString.length();i++){\n            freq[newString.charAt(i) - \'a\']++;\n        }\n        long ans = factorial(newString.length())%mod;\n        for(int i=0;i<freq.length;i++){\n            long inv = extendedEuclid(factorial(freq[i]),mod)[0]%mod + mod;\n            ans = mul(ans,inv);\n        }\n        return (int)(ans%mod);\n    }\n    public int countAnagrams(String s) {\n        String arr[] = s.split(" ");\n        long ans = 1;\n        for(int i=0;i<arr.length;i++){\n            ans = mul(ans, countPermutation(arr[i]));\n        }\n        return (int)ans;\n    }\n}\n```
['Java']