its very tricky solution
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
        O(N)

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

    O(N)


# Code
```python3 []
MOD = 10**9 + 7

def modinv(x, mod):
    return pow(x, mod - 2, mod)

class Solution:
    def countAnagrams(self, s: str) -> int:
        max_len = len(s)
        fact = [1] * (max_len + 1)
        inv_fact = [1] * (max_len + 1)
        
        for i in range(2, max_len + 1):
            fact[i] = fact[i - 1] * i % MOD
        
        inv_fact[max_len] = modinv(fact[max_len], MOD)
        for i in range(max_len - 1, 0, -1):
            inv_fact[i] = inv_fact[i + 1] * (i + 1) % MOD
        
        words = s.split()
        result = 1
        
        for word in words:
            n = len(word)
            freq = [0] * 26
            
            for char in word:
                freq[ord(char) - ord('a')] += 1
            
            word_anagrams = fact[n]
            for count in freq:
                if count > 0:
                    word_anagrams = word_anagrams * inv_fact[count] % MOD
            
            result = result * word_anagrams % MOD
        
        return result

```
['Python3']