count character frequencies then handle each character independently with memorization.
Intuitiondont do simulation as the length becomes large very quickly. instead since all chars are updated simultaneously just count their frequencies and handle
# Intuition
dont do simulation as the length becomes large very quickly. instead since all chars are updated simultaneously just count their frequencies and handle them one by one with memorization.

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

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

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

# Code
```python3 []
class Solution:
    def lengthAfterTransformations(self, s: str, t: int) -> int:
        MOD=10**9+7
        @cache
        def helper(ch,t):
            t-=(ord("z")-ord(ch))
            if t<=0:
                return 1
            else:
                t-=1
                return helper("a",t)%MOD+helper("b",t)%MOD

        res=0
        c=Counter(s)
        for ch,freq in c.items():
            res += freq*helper(ch,t)%MOD
        return res%MOD
```
['Python3']